Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ - Take standard input from a file

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.

like image 200
Karthik Bhat Avatar asked Jan 25 '19 07:01

Karthik Bhat


1 Answers

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"

like image 185
Thomas Kläger Avatar answered Nov 04 '22 03:11

Thomas Kläger