HOME      BLOG       FORUMS      CONTACT       ABOUT

Redirect standard error stream (System.err) to a file

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class SystemExample {
	public static void main(String[] args) throws IOException {
		PrintStream p = new PrintStream(new FileOutputStream(new File("c:\\temp\\out.log")));
		System.setErr(p);

		System.out.println("Hello World");
	}
}

Share

Tags: , , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply