, .
...
java ReadInput < input.txt
... , java:
java ReadInput
< input.txt (System.in).
System.in.readLine(), , , . , , ( ). , , , , .
JVM - (System.in). :
java ReadInput "Input number one" "Input number two"
. args:
public static void main(String[] args) throws IOException {
System.out.println(args.length);
System.out.println(args[0]);
System.out.println(args[1]);
System.out.println(args[2]);
}
With the code you provided, the program will exit when the result of the call to readLine () returns null. I believe that you can just press Enter on a line to send an empty line and end the program. If not, you may need to fix the program to check for an empty string (input.readLine (). Equals ("")).
Hope this helps.
source
share