I have a little problem with input in my program...(System.in, BufferedRead

I'm coding a program that takes a input like this :
Sample Input
1 11 5
2 6 7
3 13 9
12 7 16
14 3 25
19 18 22
23 13 29
24 4 28
So I wrote a code like this :
public static void main(String[] args) throws Exception{
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          String input = null;
               while((input = br.readLine()) != null) {
               StringTokenizer st = new StringTokenizer(input);
               int leftX = Integer.parseInt(st.nextToken());
               int height = Integer.parseInt(st .nextToken());
               int rightX = Integer.parseInt(st.nextToken());
.... rest of the code....
But unlike I expected, the program did not pass the while loop.
When I observed in debugging mode, when "br.readLine()" has no more strings to read,
the whole program just becomes idle doing nothing, and it does not proceed further.
Is there any problem with my code there? I've been trying to figure it out for hours... Please help!!!

myunghajang wrote:
Why doesn't it work in a way I intended? BufferedReader returns null if there is no more string to read, and what's the problem?
It's so frustrating...The computer doesn't have a mind reading input, how is your program supposed to know you have finished typing the input?
If you put the data in a file and redirect it into your program on the command line it will work (because the file knows where its end is)
Your program could instead assume that a blank line is you end of input.

Similar Messages

  • Hello, I have a little problem with my ipod (3rd generation): I restored my iPod because of problems of wi-fi, then synced my music on itunes and then on my ipod. The problem is that I still do not have wi-fi and my ipod says I have no music. Help me!

    Hello, I have a little problem with my ipod (3rd generation): I restored my iPod because of problems of wi-fi, then synced my music on itunes and then on my ipod. The problem is that I still do not have wi-fi and my ipod says I have no music. Help me!

    No. In fact, my ipod detects the livebox and the network but I can not connect to the internet.

  • I have a little problem with iphoto

    Hi, i have a little problem when i used my iphoto.
    First, i'm so sorry because my english is not fluent, but i hope that you understand me.
    The problem is that, i can't see the photos when they are vertical, i mean, when i change my photos horizontal view to vertical view, i can't see the vertical photos.
    Can you help me??? i dont understand what is the problem.
    Thanks so much.
    Lorena from Colombia

    Try rebuild the library:
    Hold down the apple and option (or alt) keys and launch iPhoto. Use the resulting dialogue to rebuild.
    Regards
    TD

  • I have a little problem with recursion.

    I have a HashMap, and I've written a method to fill it up recursively. The map size is 20.
    void fillMap(HashMap map)
    if(map.size()==20)
       return;
    //Code to fill up map
    System.out.println("Map size = " + map.size() );
    fillMap();
    }Output is like:
    Map size = 1
    Map size = 2
    Map size = 3
    Map size = 19
    Map size = 20
    Map size = 1
    Map size = 2
    and so on.
    Is there a problem with doing: if(map.size()==20)
       return;?

    yeah that was a typo.. my actual code seems to be fine that way.
    And it wouldn't compile unless I had a fillMap(*no value*) method either, right?
    I still don't get what is wrong. Here's some new code
    public class CustomMap extends HashMap
         public CustomMap()
              super(new HashMap(20));
              fillMe();
         private void fillMe()
              Object key;
              Object value;
                    if(size() == 20)
                   return;
              //--bunch of code here to determine the key and value
                    //-- I have it so no key and no value are the same, by the way
              put(key, value);
              System.out.println("Size: " + size());
              fillMe();
    }

  • Have a little problem with my domain

    Hi, I've browsed the mb's looking for the answer, but have been unable to figure this out...
    I have my hosting with godaddy and I'm not the most "technical" person, but I did the thing with the CNAME and have my .mac site with iweb '08 so that when you go to http://www.cardsfanzone.com everthing is kosher.
    However, if you just go to http://cardsfanzone.com without the WWW it takes you to a flash vid I had uploaded quite awhile back. I used to have the domain FORWARDED but I checked on godaddy and it's not set up that way anymore. Any lamen's terms ideas???

    HI Don,
    Have you tried deleting that file from the server you uploaded it to? I am guessing it is at the root of your web space, therefor it shows up first when someone uses that url without the WWW.
    It seems the file is hosted free by godaddy, so it must be on their server.

  • Hey guys , i have a little problem with the imessage ,   it woks with some friends

    the i message works good with some friends & it turns to sms with others althought they have also iphone 4s & they use it good with others, but we both cant use it together , it turns to sms . but with others it works good . any help ????????

    I've run into the same thing. Some text messages show up on my AT&T bill even though they were between my iPhone and another iPhone (or other iDevice) also running iOS version 5 or greater.
    According to this Apple help document - http://support.apple.com/kb/HT3529 - the iMessages protocol works between two iDevices that have WiFi or 3G connectivity, otherwise SMS or MMS will be used. The document doesn't specifically say, but I assume that means if one of the iDevices has a poor cell signal and drops down from 3G to Edge or a lower level of connectivity, then SMS or MMS will be used.

  • Little problem with Strings.

              I have an little problem with Strings, i make one comparision like this.
              String nombre="Javier";
              if( nombre.equalsIgnoreCase(output.getStringValue("CN_NOMBRESf",null)) )
              Wich output.getStringValue("CN_NOMBRESf",null) is "Javier" too, because I display
              this before and are equals.
              What I do wrong?.
              

    You are actually making your users key in things like
    "\026"? Not very user-friendly, I would say. But
    assuming that is the best way for you to get your
    input, or if it's just you doing the input, the way to
    change that 4-character string into the single
    character that Java represents by '\026', you would
    use a bit of code like this:char encoded =
    (char)Integer.parseInt(substring(inputString, 1),
    16);
    DrClap has the right idea, except '\026' is octal, not hex. So change the radix from 16 to 8. Unicode is usually represented like '\u002A'. So it looks like you want:String s = "\\077";
    System.out.println((char)Integer.parseInt(s.substring(1), 8));Now all you have to do is parse through the String and replace them, which I think shouldn't be too hard for you now :)

  • Little problem with Photoshop ....

    Hi. I have a little problem with photoshop CS 4. I use a color replacement tool to change a color in some details... but when i set new color, on pictures entries only or grey or black colors and nothing other... i dont known why.... please help . Thanks. Sorry for bad english

    Usually the Color mode is the one you want for the color replacement tool, you
    might have it set to luminosity or your trying replace black or white colors.
    MTSTUNER

  • Little Problem with Photoshop CS3

    Hi, I have a little problem with Photoshop CS3, I'm not sure if this's because a Windows option that I messed up, but the thing is that I didn't touch any options, or some kind of preferences.
    I'm talking about the "little windows" (I don't know the correct name) that come from, in this case, the Filter and Analysis options, they're coming down from their right side, and usually, the come down from their left side. This is really annoying.
    Not big deal, but I can't really work properly. I hope you guys can help me, and this's my first post, I hope I didn't break any rule.

    Thanks Mylenium, that was the problem, I don't even have a tablet, but that fixed my problem =)
    Thanks again.

  • A little problem with color profiles

    I am trying LR and so far I love it, it has successfully replaced RSP for me, and also beat Bibble which I briefly considered but didn't like due to the weird UI.
    However, I have a little problem with colours, which has never happened so far with other converters, and I am hoping you can help me to solve it.
    My monitor is calibrated with the Spyder and the appropriate profile loaded in the video card.
    When I work on a RAW image in LR, and then export a sRGB JPG, and then open it with a browser, or the Win viewer, I see it redder. If I open the image in Faststone, I see it almost sepia.
    If I export a TIFF and open it in PS, I see it as in LR, but when I export a JPG from PS (this is my typical workflow), the resulting image has the same problem.
    Considering that my entire workflow is in sRGB, can anybody coach me as to the correct settings I must use in order to obtain a final sRGB image with the same colors as in LR? I think that I must be doing something wrong, as the program behaves consistently with PS.
    Thank you in advance for any help you will be able to provide.
    Andrea,
    from Italy

    Funny how it's only Windows users that have this 'problem'.
    This is not a 'problem' at all. The only 'problem' here is that you've been used to using non-color-managed applications. Suddenly, Lightroom comes in as a mature, color-managed, program... and you're all going bonkers.
    Mac users aren't going bonkers because we're used to using color-managed applications (Preview, Safari, etc. are all color-managed on a Mac).
    Let me clarify for you that by 'color-managed', I mean that the software is *not only* reading the embedded profile in your image, but is *also* converting, on-the-fly, the RGB values of that image to a new set of RGB values that compensates for the native response of your monitor. Say, for example, your monitor only displays a narrow gamut of reds. Chances are, then, that LR or PS will intelligently compensate for this by saturating reds before sending to your monitor. This is how color management works. You can now imagine the disastrous effects that a bad/inaccurate monitor profile might have...
    Your Windows applications, such as 'Viewer', use the Microsoft ICM 2.0 API. This *will* read the embedded profile in an image, but instead of converting to your monitor profile for output, will simply convert to sRGB. That's basically like half-a$$ color-management. Read more about it here:
    http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/prork/prdn_img_vkev.ms px?mfr=true
    Firefox & IE don't even use the ICM 2.9 API, making them entirely non-color-managed. Whatever the raw RGB values are in your image, these applications spit out at your monitor.
    It's very important you understand these simple concepts before proceeding any further.
    OK, ready?
    The original monitor profile that came with my MacBook Pro (profiled by someone over at Apple generically for all MacBook Pro LCDs, I guess) really seems to have underestimated the gamut of my monitor. Hence, color-managed applications compensated for this be resaturating my images (especially in the oranges/reds) before outputting to monitor. Therefore, images looked really nice and saturated in color-managed applications; however, when I exported them to sRGB JPEGs and then uploaded to the web, they looked desaturated (in Firefox, NOT in Safari, since Safari is color managed). They even looked desaturated on other people's monitors (these 'other people' were your average Joes...).
    I then profiled my monitor using an i1 colorimeter. A 3-D plot of my monitor profile now showed that it actually had a much larger gamut than what Apple had predicted in their profile (but this gamut was still much smaller than sRGB, or the gamut of my Dell LCD or Sony CRT, etc.). Therefore, now, LR and PS, using this new profile, showed images much less saturated. Now when I made my edits, and then exported to sRGB JPEGs, images looked slightly *more* saturated in non-color-managed applications and on other people's computers.
    So, you see, your monitor profile affects how you make adjustments/edits in color-managed programs. If your hardware profiler profiled your monitor incorrectly (which I assume is the problem here), then you may be over-saturating certain colors within LR, skewing those RGB values so that a non-color-managed program, which will not re-correct these values as LR is doing, will display the image with too much, say, red.
    Bad monitor profiling also explains why you see this problem only on certain images/colors... if it were a LR problem, you'd most likely see it on every export. The color variance is more than likely due to a bad monitor profile that is not accurately describing your monitor's native response... hence LR/PS are incorrectly adjusting your images before sending to the monitor.
    And at this point, please don't resort to saying "but the colors in the web browser look 'right' and LR looks 'wrong'". This statement has no meaning, as what looks 'right' to you in your web browser might look horrible to someone else with a different monitor. The point of color-management is to minimize these differences. For example, I was very unhappy by how desaturated my images looked on the web compared to in PS before I calibrated my monitor. Now, images look slightly *more* saturated on the web than in LR/PS, which I'm OK with. *Should* they look the same? Heck no. Similar? Yes. Is it better if they do look the same after hardware profiling? Yes, if your main goal is web export, but, keep in mind, the only way they *would* look the same after PROPER hardware profiling would be if your monitor happened to have a very sRGB-like response (to explain this would take another few paragraphs... but you should be able to figure it out if you ponder a bit).
    I hope this is making sense. Let me ask you a couple questions now:
    1.) For your headshot image, IMG_8860, which colors look 'right' to you -- the colors in LR, or the colors upon export (i.e. the headshot on the left or the right in your link above)?
    2.) How exactly did your profile your monitor? Was it in the dark? I had quite a bit of variance in my monitor profile depending on whether or not the Mac OS X dock was visible at the bottom of the screen -- the light from the dock leaked into the colorimeter which then led to profiles that generated yellow/green color casts.
    -Rishi

  • I have very strange problem with Iphone 3gs. Whenever it gets little hot or exposed to 30 degree temperature it losses signals (No service). Whenever it is cooled down the service is back. Please help!

    I have very strange problem with iphone 3gs. Whenever it gets little hot or exposed to 30 degree or above temperature it losses signals (No service). Whenever it is cooled down the service is back. Whenever I am using Skype or playing game for a while it losses carrier signals and wifi. When it is cooled down afer shutting down the carrier signals and wifi are back. It is for sure problem is with heating, but 30 degree tempeature in Oman is normal and some time it goes upto 50 degrees. I have noticed this has started after I started using substandard charger as I lost my original charger of the phone. Please help!! Thanx.

    The specifications define an operating range up to 35 degrees.

  • I have been having problems with my iPod touch and my WRT...

    I have been having problems with my iPod touch and my WRT54G router. I am so frustrated right now because after following the various steps mentioned in one of these threads, following Earthlink's prompts, and speaking with Apple, my iPod touch will still not work. It is connected to the internet but will not download the pages. It is quite frustrating. I have changed from WPA to WEP, I switched the 4th Generated key to the 1st. I've disabled this, enabled that. I've done just about everything. I updated the firmware. I made the switch from a partial bridge to a full bridge. Still nothing seems to work. Does anyone have any other suggestions? The one thing I have not done is enter the Apple code into the iPod which searches for website...-- I cannot access the internet with my iPod so this web address does not work. If anyone has been successful, will you please give me step by step instructions? Yesterday I was on the phone with Linksys for about an hour. Before that with Apple for about an hour and before that with Earthlink. How it is that I can walk into a Bread Co. or Apple Store and immediately connect to the internet with my iPod but I can't in my own house?? Everyone seems to think it is someone else's problem so I've gone around and around. Not one of the Linksys support personnel suggested I look here on this community forum. I had to pay the $9 fee to have advanced Linksys help but still my iPod does not work and when I called back, the man I spoke with seemed to think the case was closed because my PC, Laptop, and iPod are connected to the internet -- the iPod just won't download the webpages or get mail. My iPod's IP address begins with 192. I would appreciate any help on this matter
    Message Edited by AlliW on 10-02-2008 02:06 PM

    I had the same issues with my iPod touch & iPhone. It's a known issue with the touch & Linksys G routers. Go into settings on the touch & do the following.
    1. Settings - wifi - linksys
    2. Erase your DNS settings & input same numbers as in router
    Settings.
    3. Http proxy should be
    in off position.
    4. Close out & open safari you should now have a wireless
    connection.

  • I installed Mavericks yesterday and have now got problems with QuarkXpress 9. Every time I click on an image and try to move it the application crashes. Anyone had similar problems or got any suggestions?

    I installed Mavericks yesterday and have now got problems with QuarkXpress 9. Every time I click on an image and try to move it the application crashes. Anyone had similar problems or got any suggestions?

    Hi Guys
    Updated my 2 imacs to Maverick yesterday. Schoolboy error on my part not checking if there were problems with any programmes before I did.
    Quark is now a nightmare with no short term answer on the way. As a Quark user for over 20 years this is just another reason to hold your hands up and say OK Indesign you win I will have to learn how to use you and Quark will be a distant memory.
    I am told there will probably be no solution to getting quak 9 running on Maverick and that you will need to update to 10 in about 2-3 weeks to get back to normal. Having spent a few bob on 2 versions of 9.5 only in Feb this year i didn't really want to upgrade yet.
    So its cough up to carry on using Quark or learn Indesign.
    I have lost faith in Quark as they are quick to send me e-mails asking me to upgrade to this and that version, why didn't they send one out saying do not upgrade to Maverick. Perhaps they know there loyal follwing will uograde to 10 and will generate a nice little bonus before Xmas.
    Lots to do today and will now take 10 times longer to do it. Is this 2013 or 1974!!!!!
    If anyone hears of a solution please post ASAP

  • HT6065 I installed this update.  I have never had problems with "multiple prompts to unlock "Local items" keychain" until after I installed this update.  Now, I can't get it to STOP prompting me.

    So how do I fix this?  How do I get this to go away?  It's prompting me for a password that I haven't ever set up!

    I have the same problem with three pop-up prompts:
    (1) com.apple.iCloudHelper wants to use the "login" keychain. Please enter the keychain password.
    (2) CalendarAgent wants to use the "login" keychain. Please enter the keychain password.
    (3) AddressBookSourceSync wants to use the "login" keychain. Please enter the keychain password.
    I can enter my login password and the prompt goes away for a little while, but eventually returns.  Or I can click on "Cancel" many multiple times and it goes away for a little while, but returns again.
    I want a solution too and hope this additional information will help.

  • Problems with Input Ready Query

    Hello All,
    I'm facing problems with input ready query for BI IP.
    I've created the input query on aggregation level and maintianed all the planning settings.  It is not allowing me to edit, when i'm attaching in the web template.
    I also attached a button copy function, and i'm able to execute it and save it, but it not allowing me to change manually.
    I also enabled the 3rd option for keyfigures...data can be changed with planning functions and user input.
    Please help me in this regard.
    We have just started the development of BI-IP, please suggest me if there are any notes to be applied.
    Regards
    Kumar

    Hello Johannes,
    Yes I've set to the finest granularity...even if it is Only one characteristic and one key figure without any restrictions...
    I've checked even planning tab page under properties...it is also fine..
    But still it is not allaowing me to go to edit mode...this is a fresh instalation and the query i'm working is the first one...
    Please suggest me if there are any notes to be applied, we are on Support Pack 10.
    Regards
    Jeevan Kumar

Maybe you are looking for

  • G3 iBook having dial-up connection issues

    iBook 500MHz G3 running 10.3.9 My Dad's computer is acting very, very strange. He's got a dial-up with connection, which is admittedly slow. This affects both Safari & Firefox when he's browsing the 'net. Lately (past few months, off and on) it's bee

  • Who to make use of bridge table in the report

    hi all, I have two tales let us say T1 and T2, having may to may relation .. if i take the one column from T1 table and another column from T2 table in the report.. it is taking more time to generate. What is the problem, why they have interested Bri

  • I've just bought an ipod 5 but I can't activate it.

    i've just bought an ipod 5 but I can't activate it. help

  • Bluetooth not working.  Greyed out after using hotspot

    My bluetooth and wifi stopped working after I used hotspot.  It is greyed out and I cannot get it working.  I have re-set the settings in general.  Anyone have any ideas?

  • Pictures of 4GB Card Working on N80

    Just spotted an ad on ebay which has pictures of an N80 running v3.0617.06 firmware with a working 4GB card - shows it with more that 2GB of data, too. Has anyone actually got a 4GB card working in an N80? The ad states that the v3.0617.06 firmware i