I am trying to redirect the output produced in a Java program into another file("output.txt") located in the same location. I found help on it from here . But when I try the same method I find that my file "output.txt" remains empty. My code looks like this:
System.setOut(new PrintStream(new FileOutputStream("output.txt")));
System.out.println("hello");
Could somebody please point out my mistake here. Thank you in advance for your help.
就像在这个答案中所说的,您应该尝试将autoflushing设置为true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.