Yes you can set FileOutputStream Object to override default out implementation as follows:
=================================================
File f = new File("testOut.txt");
FileOutputStream fos;
try {
fos = new FileOutputStream(f);
PrintStream pos = new PrintStream(fos);
System.setOut(pos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.print("Hello world File");
=================================================
No comments:
Post a Comment