Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: Help with a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 16048 of 16590
Post > Topic >>

Re: Help with a loop

by "Tim B" <nospam@[EMAIL PROTECTED] > May 17, 2008 at 01:42 AM

"Fish" <Fish@[EMAIL PROTECTED]
> wrote in message
news:pccp14d7jbtdurf5dme06n5e7952ji7pue@[EMAIL PROTECTED]
> Could a kind Java code expert take a look at a method for me?
>
> It seems that once called, the method starts out good by
> creating/opening up a file (appending existing files).  It hiccups
> when it gets to the do loop.  It asks the first question, then without
> waiting for data to be entered, it asks the second question.  This
> only happens on the first iteration of the loop.
>

(snip)

> Scanner keyboard = new Scanner(System.in);
> String fileName = keyboard.next();


If you change the above line to :
    String fileName = keyboard.nextLine();
the problem goes away. I'm not sure why exactly, but maybe next() leaves
something in the input that is picked up by the first nextLine() in the
loop.
 




 4 Posts in Topic:
Help with a loop
Fish <Fish@[EMAIL PROT  2008-05-03 13:42:17 
Re: Help with a loop
"Jeff Higgins"   2008-05-03 15:05:38 
Re: Help with a loop
Mark Space <markspace@  2008-05-04 01:27:30 
Re: Help with a loop
"Tim B" <nos  2008-05-17 01:42:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 15:52:00 CST 2008.