import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.sql.Timestamp;
public class MainClass {
public static void main(String[] args) {
try {
String FILE = "c:\\systemin.txt";
FileOutputStream outStr = new FileOutputStream(FILE, true);
PrintStream printStream = new PrintStream(outStr);
System.setErr(printStream);
Timestamp now = new Timestamp(System.currentTimeMillis());
System.out.println(now.toString() + ": This is text that should go to the file");
outStr.close();
printStream.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
System.exit(-1);
} catch (IOException ex) {
ex.printStackTrace();
System.exit(-1);
}
}
}