//This application might help you.
//
Java code to read console input from a Microsoft DOS command line
import java.io.*;
public class ReadConsole {
public static void main(String args[]) throws IOException {
// declare your InputStream and OutputStream objects
InputStream inStream;
OutputStream outStream;
int inChar;
// assign System.in to inStream and System.out to outStream
inStream = System.in;
outStream = System.out;
System.out.println("Reads input from console ... Ctrl+Z to quit.");
System.out.println("After Ctrl+Z, writes console input on monitor .... ");
// read (that is, execute the loop)
// from console until end-of-file (Ctrl+Z)
try {
while ( ( inChar = inStream.read() ) != -1 ) {
outStream.write( inChar );
}
}
// catch block to handle IOException:
catch ( IOException ioe ) {
System.out.println( "Error: " + ioe.getMessage() );
}
// ensure that streams are closed
// irregardless of whether an IOException occurs
finally {
inStream.close();
outStream.close();
}
}
}