I need to take standard input from a file in IntelliJ IDEA.
$ java BinarySearch tinyW.txt < tinyT.txt
'tinyT.txt' is the file which is to be taken as standard input. 'tinyW.txt' is another file which is passed as a command-line argument to the program.
How can this be achieved through IntelliJ?
PS: I am not running this program from the command-line as the class-path variable hasn't been set, and I am using functions from external libraries.
You need to create a "Run/Debug Configuration" (Menu "Run" -> "Edit Configurations...").
About halfway down in the configuration panel is an entry "Redirect input from" with a checkbox before it. After selecting the checkbox you can select the file "tinyT.txt".
"tinyW.txt" has to be entered into the field "Program arguments"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With