Keyboard input using BufferedReader

Trying to use BufferedReader for keyboard input, first of all is it possible? And second how do I do construct the stream?
I am trying BufferedRead in = new BufferedReader(System.in); and this is not working .
Please help.

Trying to use BufferedReader for keyboard input, first
of all is it possible? And second how do I do
construct the stream?
I am trying BufferedRead in = new
BufferedReader(System.in); and this is not working .
Please help.Try this. I got it from Core Java 1.2 Volume 1 - Fundamentals by Horstmann and Cornell:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));To read something from the console at that point you'd do something like this:
String inputData=in.readLine();Hope that helps.

Similar Messages

  • Alternative ASCII characters for standard keyboard input using TextEdit?

    Hi, how can slight variations to characters be made on the fly while typing in TextEdit? For example, using Option + O I'm able to type "Ø"...how can I type other "variations" of O...with accents, umlauts, etc? thanks

    Choose Show Keyboard Viewer from the menu with the flag icon. If it doesn't appear, open the International pane of System Preferences to enable it and the input menu.
    (48307)

  • Keyboard input regardless of focus

    Dose anyone hav a way of accepting keyboard input using keyListeners or something else even when my Jframe windowis not the window in focus?
    Any help is appreciated.

    pinktux777 wrote:
    Yea, I suppose...
    I was hoping not to, but it looks like I will be going that way.
    The project I'm working on is a "challenge" by my teacher based on the AP Java "Gridworld" environment. I'm not sure if modifying the environment itself meets the restrictions of the challenge, but that seems best from a strict programming aspect.
    If anyone has a solution to my original problem, I'm still interested.Whoa, I'm not sure that you want to modify any code here. You'd be much better off seeing if you can subclass from this code rather than modify. That's what OOP is all about. Even if the JFrame you are talking about is private, there still may be ways of using OOP to modify its behavior. BTW, what is "gridworld"?

  • How to use the phone's Mini-Keyboard Input with the 'Textbox'(MIDP2.0)?

    (My apology. My English is not perfect but I'll try my best. >_<)
    Hi. I'm trying to create a textbox(in my own little application) that is compatible with the mini-keyboard input feature.
    This problem involved any device that have a built-in "mini-keyboard".
    Problem:
    I tried the 'Textbox' class from MIDP2.0 but the result, as expected, is like using the phones with no built-in keyboard.
    (Forexample if I want to input the character 'C' inthe text box, I need to press number '2' button three times to let it circle through 'A' -> 'B' then 'C'. )
    Then I tried entering URLs in the phone's built-in web browser, the result is I can use the mini keyboard to type like a PC keyboard.
    Question: How do I implement such textbox that is fully compatible with the built-in mini Keyboard?
    I tried browsing through the MIDP2.0 API but it seems the 'Textbox' class there couldn't do it.
    Thank you. =)
    /bow
    Edit/Delete Message

    The textbox should have input just as any other normal phone input. If not, something strange is going on.
    Anyway , there is no use to make your own input method, since every phone has another implementation of this anyway. It would only confuse users.

  • Default Keyboard input change in using roaming Profile on different Win 7

    We found a strange problem on default Keyboard setting.
    We are using roaming profiles for all users.
    One of our users is using two Windows 7. One Windows 7 is VDI for working out of office and another Win 7 is her local PC.
    She is only using Two keyboard input: Chinese Traditional English and Chinese Traditional Pinyin.
    Whenever she had used the Windows 7 VDI, when she comes back to office and use her local PC, the default Keyboard input will automatically change to Chinese Traditional Pinyin.
    The user said she had not changed any default keyboard input in the VDI of local PC.
    Is there anything we can do for this issue?
    Ivan

    Hi Ivan,
    I am just writing to check the status of this thread. Was the information provided in previous reply
    helpful to you?
    Do you have any further questions or concerns? Please feel free to let us know.
    If you have any feedback on our support, please click
    here
    Karen Hu
    TechNet Community Support

  • Using Firefox 3.6 after a few mouse click/ keyboard input the firefox window is no more active, mouse click and keyboard input is inactive ; then I click on the taskbar and the keyboard is active again during a few click then it stops again etc.

    Using Firefox 3.6 after a few mouse click/ keyboard input the firefox window is no more active, mouse click and keyboard input is inactive ;
    to solve it I click on the taskbar and the keyboard is active again during a few click then it does not work any more and I click again on the task bar etc.
    after several repetitions, I have to call the task manager alt+del+ctrl, then come back to the firefox window to be able to use keyboard and mouse again

    Attaching the picture for the tab shape I want...

  • Is there a way of using keyboard input?

    Is there a way of using keyboard input in Edge? For example when you press the space-bar it will open a url. This is probaly done though programing.

    Shift/Command and Alt/Control have there own separate event routines.
    Example
    e.metaKey         // depends on browser and targets the Apple key
    e.ctrlKey             // targets the Control or Ctrl key
    e.altKey              // targets the Alt key
    e.shiftKey           // targets the Shift key
    So if you only wanted the event to fire when the Shift key is pressed, then
    if (e.shiftKey){                                              //If Shift key is pressed 
           window.open("http://www.adobe.com", "_blank");
    If you wanted to combine the Shift key + Space Bar to trigger the event, then resort to logical operators. In this case you want to 'combine' key strokes, then the logical operator would be a double &&, and demonstrated below.
    if (e.shiftKey && e.which == 32){                     //If Shift Key + Space Bar pressed
          window.open("http://www.adobe.com", "_blank");
    If you wanted to combine the Shift key + some other keyboard Character Code from the above noted list (http://rmhh.co.uk/ascii.html), then change the value of e.which to equal (==) that Character Code. Example from the list, the Character Code for the keyboard 'a' is 65, as altered below.
    if (e.shiftKey && e.which == 65){                     //If Shift Key + A pressed
    window.open("http://www.adobe.com", "_blank");
    To get an accuarte keycode value, there are two demonstrations on this page http://api.jquery.com/event.which/, whereby you can type in thee field and it will capture the value for you.
    Good luck
    Darrell

  • How do i get keyboard input?

    When I wrote programs in my high-school AP class we always imported a keyboard class and used Keyboard.readInt or .readChar or whatever type. I've downloaded the keyboard class but don't know where to put it so I can import it to my programs and I don't know of any other ways to get keyboard input and the string tokenizer method is a bit confusing. Any help would be much appreciated, thanks a lot.

    Hello Fignut,,
    this is the forum for the JavaHelp product, not for general java programming questions.
    Unfortunately I have no supernatural powers to know how your Keyboard class looks like, so I can offer only a solution with the standard API
        String line;
        try
        { BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
          System.out.println("Enter your text. Finish with <Ctrl>Z and <Ret>.\n");
          while((line = in.readLine()) != null)
          { System.out.println("Echo: "+line);
          in.close();
        catch (Exception e)
        { System.out.println(e);
        }Regards
    J�rg

  • HttpServer error in reading buffer size via keyboard input - HELP

    I've written a simple HttpServer program that reads keyboard input to construct a buffer to copy the requested file into the socket's output stream. I've done the string-to-integer conversion using BufferedReader and parse.Int. However, when I go to use the int later in the program, I keep getting the message "variable b may not have been initialized." Can anyone tell me what's missing from the code below? Thanks.
    private static void sendBytes(FileInputStream fis, OutputStream os)throws Exception
         //Construct a buffer via console input
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str;
         int b;
              System.out.println("Enter desired buffer size or CTRL-C to break.");
         //Convert entry to an integer
         do
              str = br.readLine();
                 try
                   b = Integer.parseInt(str);
              catch(NumberFormatException e)
                   System.out.println("Invalid entry.");
         while((str=br.readLine())!=null);
         //Construct a buffer
         byte[] buffer = new byte;
         int bytes = 0;
         //Begin timing HTML page delivery
         long start, end;
              System.out.println("Timing for Web page delivery");
         start = System.currentTimeMillis();
         //Copy requested file into the socket's output stream
              while((bytes = fis.read(buffer)) != -1)
              os.write(buffer, 0, bytes);

    As the message suggests, what is missing is code to initialize the variable b. The first mention ("int b;") does not initialize it. The second mention ("b = Integer.parseInt(str);") only initializes it if no exception is thrown. So it's possible for b to be uninitialized when you actually try to use it.
    What do you need to change? First you need to decide what's to be done if the keyboard input isn't a valid integer. Do you have a default value in mind? If so, put that where you declare the variable ("int b = 42;"). If not, just initialize the variable to zero ("int b = 0;").

  • Capture keyboard input

    I have a swing app that will run on a touch screen. There will be no keyboard. I will have a magnetic card reader plugged into the ps/2 port.
    Basically I need to capture the output of the magnetic card reader. At the moment when a card is swiped it goes in the first JTextfield.
    Now I can capture the output outside of swing by using
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String data = stdin.readLine();
    System.out.println(m_data);
    However this does not work inside of swing or at least my swing app.
    So in swing, how can I capture or redirect text input?
    I guess I could write a fuction that appends a character each time a key event occurs like KeyTyped. However I am not sure that is the most efficient way to go about it.

    A document listner might work, however I think that url you posted also shows a way using an action listner.
    Something I forgot to mention was, when I swipe the card I do not want the card's data placed in a JTextField.
    To the point when a card is swiped I want the data in a string.
    At the moment when I swipe a card it goes into a JTextfield. I do not want that to be the case. Sure I can make a way around it with a hidden text field or something, and use a listner for events on the text field.
    However I do not think that is the proper way to go about this.
    So I am looking for an event that will be fired or take place as soon as there is input from the keyboard/card reader. I do not want a JTextField to even have the chance to grab and display that data. I want to know first, and take that data and do something else with it.
    In detail, when a card is swipped, the data will be parsed and JTextFields will display the parsed information. However I need to be the first one receiving the data, not any of the JTextFields in my app.
    The app does not require use of a keyboard. If possible I would like the app to not work at all with a keyboard, and any input from a keyboard or card reader is calling my own code to deal with those events.
    So if someone does plug in a keyboard, I do not want them to be able to do anything. That's not a must, but if I can accomplish it with the above I will be a happy camper.
    In short I need to capture all input from the ps/2 port, and be notified with input starts and ends. Or at least when it ends.
    Any suggestions are greatly appreciated.

  • Diff bet  args and using BufferedReader(new InputStreamReader(System.in))

    What is the differece between getting a string via args and using BufferedReader(new InputStreamReader(System.in))??????
    Please help me to know

    via argsI presume you mean the command line arguments? Well that'd be the command line arguments: ergo: "Hello World" would be the arguments in: java -cp . Say "Hello World"
    System.in is the standard input stream... The console (ie the keyboard) when a java program is run within a "standard" command line environment.
    Cheers. Keith.

  • TS3280 How can i enable both paired bluetooth and ios keyboard input at the same time?

    How can i enable both paired bluetooth and ios keyboard input at the same time?
    This is needed for the app im working on. Need some user input via keypad as well as scanner input via a paired bluetooth scanner.

    You probably should not be using a keyboard bluetooth profile for a scanner, I am not a developer for apple so do not know the location for you to find out the correct profile you should be using for an input device that is not a keyboard. Sorry,
    I am sure if you navigate the apple developer site you will probaly finmd what you're looking for.
    https://developer.apple.com

  • How to have same keyboards input source in Mac and Windows???

    I use Canadian French-CSA on my Mac keyboards input source. Using Windows 7, I can't find the good setting for my keyboards to be the same when I it keys.
    I run Windows over Parallels Desktop
    Can anybody help?
    Thank you

    Can I use an AirPort Extreme Base Station "n"
    Yes.
    and if so, will my MacBook work with this at maximum download / upload speed (i.e. equivalent to the cable)
    The speed of your internal network generally is much much faster than the speed of your internet connection. Unless he has an internet connection faster than approx 6Mbps then even dropping down to the old 802.11b Airport would not seen any decrease in speed of downloads etc...
    and will my brother's PC's also be able to connect?
    If his PC is 802.11b/g-compliant, it shouldn't have any problems connecting to the AirPort base station.
    Or is there another Airport base station?
    The other AirPorts would work, but the AirPort Express & older 802.11g AirPort Extreme base stations have a max. range of 150 feet.
    OR-- should I head down to "Generic Computer Store" and just by a wireless router (WiFi)(think that's what they call them) and connect this to his cable modem? IF SO WILL THAT WORK FOR MY MAC?
    That is always an option as well, especially since he will be the primary user throughout the year. I'd suggest going with a brand name, like Belkin, D-Link, or Linksys for the wireless router choice.

  • Firefox and Thunderbird are suddenly not accepting keyboard input

    Keyboard shortcuts still work just input in any kind of input field fails so I can still use ctrl+C / CTRL+V to somewhat use firefox and Thunderbird But all input fields are completely unresponsive to keyboard input
    The problem suddenly arose while I was browsing.
    I have the same issue on all program's based on the Gecko engine and I confirmed them so far in Firefox, waterfox, instantbird, thunderbird and fossamail. However chromium / windows / basically everythign n
    To fix it I tried the following:
    Restarting firefox
    Restarting firefox in savemode
    Rebooting
    Changing the keyboard layout in windows
    Using a different keyboard
    Again rebooting
    Pressing F7 to check for caret mode which was disabled
    pressing winkey + F9 (Whatever that does)
    I am running windows 8.1(x64)

    Solved, Changing the keyboard layout again and rebooting fixed it. I tried using the on screen keyboard which worked so I changed the keyboard layout again and rebooted and now it works just fine. I still wonder what caused a Gecko wide issue like this?

  • CS3 Language Keyboard Input Error

    Greetings All,
    I have been trouble-shooting this problem for a while, but still it is not resolved. Any help or ideas would be gladly received!
    Background: We have a correctly functioning installation of Win XP, and PS CS3 Extended which appears to work normally in every other regard. No obvious errors; no crashes, no start-up complaints; nothing seemingly out of order. I use several installed languages in Windows (EngUK, Russian, Swedish, etc). All of these work normally. All of my installed fonts work correctly in every application on the system except for CS3.
    There would appear to be something wrong with CS3's keyboard mapping in foreign languages. When typing with a non-English keyboard setting (any other language) and using TrueType fonts (not Open), only 'missing character' boxes appear in the artwork. The Layers menu displays the typed text correctly, but this will not appear in the artwork. If I use an old install of PS7, I can type using these same fonts correctly in any language. These layers can be imported into CS3, and these WILL display correctly on the artwork. However, the Layers menu in this case displays nonsensical characters. Ergo, I suspect that CS3's keyboard input data is errant.
    Where does PS3 keep its information regarding language / keyboard layout? It is possible to edit this file(s)? Are there any other ideas regarding this problem and what might be wrong?
    Thanks

    Unicode vs. non-Unicode. Turn off glyph substition in the character palette.
    Mylenium

Maybe you are looking for

  • Credit card charged rather than iTunes gift card credit taken. How do I correct payment method?

    A friend recently gave me an iTunes card which I credited to my iTunes account. I've just downloaded a movie and wanted to use the credit from my card to pay for this. Instead iTunes appears to have charged my credit card rather than using the existi

  • Error in Essbase 11.1.1.3 Installation.

    Hi Gurus, I have sucessfully installed the Essbase 11.1.1.3 & when i am trying to do the shared services configuration i am getting an error like " Login failed for user dbadmin. User is not associated with a trusted sql server connection". I have in

  • Picture quality, new camera?

    I bought a new HD camcorder last year the the Sony Hc7. I made a movie with FCp and Color, you can view it here: http://www.vimeo.com/1949150 But still the picture quality is not as good as I want. Anyone know if I will get a significantly better pic

  • FM for Download

    Hi guys, I have a requirement wherein i need to download data from my internal table in a file on the desktop of the user who is running it Atuomatically, the user will not provide any filepath. Can any one inform me about the Function Module for the

  • Missing datasources

    Hello, Can someone help me with the following problem. I miss some datasources when I replicate in BW (7.0). In CRM (5.0) I check whether these datasources were available or not. But they were not. I miss the following datasources: 0CRM_SRV_COSTS 0CR