Reputation: 998
This is a question which is different from
How do you input commandline argument in IntelliJ IDEA?
The point of this question is, run with the redirct symbol
<
So in command line I can do this
java -cp /classpath MyClass < data.txt
which works good.
But I followed official help document of Intellij and tried to put redirect symbol < in argument.
Intellij threw an
Exception in thread "main" java.lang.IllegalArgumentException.
And I didn't find any illustration about using redirect symbol < with arguments in official help document.
Upvotes: 2
Views: 2307
Reputation: 11
IntelliJ does not support redirect symbol for now. It's really painful~!
As a compromise, you could try:
FileInputStream fis = new FileInputStream("E:\\GDUT\\Dropbox\\Alg4\\test_data\\eval.txt");
System.setIn(fis);
https://youtrack.jetbrains.com/issue/CPP-3153#tab=Comments
Upvotes: 1
Reputation: 131
For the Program Arguments field, put in a path to the file, instead of the redirect symbol.
So if your IntelliJ project main directory is
/home/glenn/Proj_java/Algorithms/Chapter1/BinarySearch
and your file data.txt is in that directory, just put in this:
data.txt
If you had a subdirectory under that named "mystuff" which contained your file, in Program Arguments use the relative path to the file:
mystuff/data.txt
Upvotes: 2