Re: how i can read from console ?
Posted By:
Eric_Lindauer
Posted On:
Wednesday, March 20, 2002 07:30 AM
There are many classes in the java.io package for handling streams. You just need to read lines from System.in, as in the example below:
import java.io.*;
public class MyClass {
public static void main ( String[] args ) throws IOException {
String command = "";
BufferedReader in = new BufferedReader (
new InputStreamReader (System.in));
while ( ! command.equals ( "quit" ) ) {
System.out.print ( "type something>" );
command = in.readLine ();
System.err.println ( "You typed " + command );
}
System.err.println ( "goodbye" );
}
}
Hope this helps.
-Eric