import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;
public class SystemOutTest {
public static void main(String[] args) throws Exception {
String property = System.getProperties().getProperty("user.home");
String filePath = property.replace("\\", "/");
String fileName = filePath + "/out.txt";
try {
System.setOut(new PrintStream(new FileOutputStream(fileName)));
while (true) {
Thread.sleep(5000);
System.out.println(new Date());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}