From: Chad Newsgroups: comp.lang.java.programmer Subject: How can I read from the entire standard input at once? Date: Tue, 27 Sep 2011 18:34:05 -0700 (PDT) Organization: http://groups.google.com Lines: 79 Message-ID: NNTP-Posting-Host: 66.81.50.84 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1317173756 30638 127.0.0.1 (28 Sep 2011 01:35:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 28 Sep 2011 01:35:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g23g2000vbz.googlegroups.com; posting-host=66.81.50.84; posting-account=kTs1ygoAAACgG1TSoyECpovEyy-V6_8b User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2),gzip(gfe) Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!feed.ac-versailles.fr!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!g23g2000vbz.googlegroups.com!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8377 The following code is a stripped down version of a large project. The question is why do I have to press ctrl z every time to get the output? That is, say I type the following at the command line 1 - 3 and then press the enter key on my keyboard. I press ctrl z and I get 'The value is 1' . Then I press it again, I get a 'The value is '. Then I press it again, I get 'The value is -', etc. Ideas on how to get how get the entire output out at once? Ideally what I would like to do is when I type in the above, press the enter key, then, after I press ctrl z, get The value is 1 The value is found the minus sign The value is 3 import java.util.Scanner; public class hack { public static int getNextNumber(String [] storeValues) { String value = null; int i = 0; Scanner input = new Scanner(System.in); while(input.hasNextLine()) { try { storeValues[i++] = input.nextLine(); } catch (IllegalStateException e) { return -1; //EOF } } return 0; } public static void main(String[] args) { String[] values = new String[100]; char[] getNumber; int value; int i = 0; while ( ( value = getNextNumber(values) ) != -1) { getNumber = values[0].toCharArray(); switch (value) { case 0: { System.out.println("The value is " + getNumber[i]); i++; break; } case '+': { System.out.println("found plus sign"); i++; break; } case '-': { System.out.println("found minus sign"); i++; break; } case '*': { System.out.println("found mult sign"); i++; break; } case '/': { System.out.println("found division sign"); i++; break; } default: break; } }//end while }//end main()