Command Line Pipe Input in Java

By executing "java Read < input.txt" you’ve told the operating system that for this process, the piped file is standard in. You can’t then switch back to the command line from inside the application.

If you want to do that, then pass input.txt as a file name parameter to the application, open/read/close the file yourself from inside the application, then read from standard input to get stuff from the command line.

Leave a Comment