首页 > 代码库 > How to save console output to a file in Eclipse

How to save console output to a file in Eclipse

https://coderanch.com/t/278299/java/Writing-output-console-file-system

 

File file = new File("test.txt");
FileOutputStream fis = new FileOutputStream(file);
PrintStream out = new PrintStream(fis);
System.setOut(out);
System.out.println("First Line");
System.out.println("Second Line");
System.out.println("Third Line");
System.out.println("Fourth Line");

How to save console output to a file in Eclipse