public static void main(String[] args) throws Exception {
ABC abc = new ABC();
PrintStream printStream;
printStream = new PrintStream(new FileOutputStream("C://javaout.log"));
System.setOut(printStream);
System.setErr(printStream);
System.out.println("I am from Out...");
System.err.println("I am from Error");
}
Now check the javaout.log in c drive
Redirecting exception' printStackTrace to a file
catch(Exception e){
: : :
e.printStackTrace( new PrintStream(("C://javaout.log")));
: : :
No comments:
Post a Comment