Is it possible to redirect Kotlin stdio
to files through command line parameters, something like < input.txt > output.txt
?
If not, is there any simple way?
I'm using IntelliJ IDEA.
If you run the program with an IntelliJ IDEA run configuration, then you can configure it to save the console output to a file.
Open the run configuration settings:
In the Logs tab, check Save console output to file and enter the file name:
Redirecting is possible for Java applications as per this Q&A, but this option seems to be missing for Kotlin. This is a known issue, please vote and follow https://youtrack.jetbrains.com/issue/KT-28854
Redirecting the input and output with <
and >
is the shell feature, and passing these arguments to the JVM or your program won't make any effect.