Here is the class i created for redirect println to a specific file, my question is how to redirec whatever print out in the System.out.println(...) and System.err.println(...) into a different file? And How come it looks weir when i have special character like a new line (\n)? Can i write any type of object into printstream file?
import java.io.*;
public class RedirectFile
{
FileOutputStream out = null;
FileOutputStream in = null;
FileOutputStream err = null;
PrintStream outFile = null;
PrintStream inFile = null;
PrintStream errFile = null;
public RedirectFile()
{
try
{
out = new FileOutputStream("c:\\temp\\mindy\\out.txt");
in = new FileOutputStream("c:\\temp\\mindy\\in.txt");
err = new FileOutputStream("c:\\temp\\mindy\\err.txt");
outFile = new PrintStream(out);
inFile = new PrintStream(in);
errFile = new PrintStream(err);
outFile.println("this is a
testing page");
inFile.println("this is a testing page call inFile....\n");
errFile.println("print the error file...\n");
System.err.println("oops........error");
System.out.println("yeah..out put is ...here ");
}
catch(IOException eIo)
{
System.out.println("can not create file");
}
}
public static void main(
String[] args)
{
new RedirectFile();
System.exit(0);
}
}
[This message has been edited by Mindy Wu (edited July 20, 2001).]