|
|
Re: I cant redirect the output to a file [message #1178052 is a reply to message #1168944] |
Sat, 09 November 2013 10:53 |
Arnav Kumar Messages: 16 Registered: October 2013 |
Junior Member |
|
|
Try this to print output file
import java.io.FileNotFoundException;
import java.io.PrintStream;
public class SOPinTxtFile {
private void writeFile(){
System.out.println("hello ji from method");
}
public static void main(String[] args) {
try {
System.setOut(new PrintStream("c:\\output.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println("From main");
new SOPinTxtFile().writeFile();
int a=10,b=10;
System.out.println("Division is "+a/b);
}
}
You may use log4j for this puropose.
TechKnowHeights
[Updated on: Sat, 09 November 2013 10:56] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03345 seconds