Skip to content

Instantly share code, notes, and snippets.

@mgronhol
Created April 11, 2012 10:02
Show Gist options
  • Save mgronhol/2358345 to your computer and use it in GitHub Desktop.
Save mgronhol/2358345 to your computer and use it in GitHub Desktop.
Java simple read line from stdin.
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