How to let Java program read txt file as input in IntelliJ IDEA

  java, question

图片描述

How to let the compiled Java program read txt file as input in IntelliJ IDEA (do not write the code of Java read file).


java  Example.java < example.txt

This command is similar to the one that implements the terminal inside to run java programs.

Yes, any mature IDA has this function. vs, eclipse and idea all have this function.

Jetbrain’s documentation

In this interface, you fill in your parameters. It is in the column of Program arguments.

图片1

Keep it, run will do.

Running results

图片描述