Created
April 11, 2012 10:02
-
-
Save mgronhol/2358345 to your computer and use it in GitHub Desktop.
Java simple read line from stdin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class stdinReader1 { | |
public static void main( String args[] ){ | |
System.out.println( "Moi kaikki!" ); | |
try { | |
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) ); | |
String input = new String(); | |
while( input.length() < 1 ){ | |
System.out.print( ">" ); | |
input = reader.readLine(); | |
} | |
System.out.println( "You typed: '" + input + "'." ); | |
} | |
catch( Exception e ){ | |
System.out.println( "An exception occured!" ); | |
System.out.println( e.toString() ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment