您不需要Java网络启动即可执行任何上述操作。只需将设置为
System.out即可
FileOutputStream。
System.setOut(new PrintStream(new FileOutputStream(fileName)));
fileName您要传送到的文件的完整路径在哪里。
public static void main(String[] args) throws Exception { //Read user input into the array System.setOut(new PrintStream(new FileOutputStream("home.txt"))); System.out.println("hello");}将写入当前工作目录中
hellon命名的文件
home.txt。
如果您无法修改代码,请在Windows
7上使用命令重定向。
java YourMainClass > home.txt
如果需要运行jar,可以使用java应用程序启动器的
-jar选项。
java -jar /your/path.jar > /output/file/path.txt



