File file = new File("c:/a.txt");
PrintStream fi = null;
try {
fi = new PrintStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.setOut(fi);
PrintStream fi = null;
try {
fi = new PrintStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.setOut(fi);
本文提供了一个使用Java进行文件输出流操作的例子。通过创建File和PrintStream对象,将输出流定向到指定路径的文件中。该过程包括异常处理机制。
463

被折叠的 条评论
为什么被折叠?



