private static final String FILENAME = "c:\\temp\\out.txt"; PrintWriter pw = null;
try {
pw = new PrintWriter(FILENAME); pw.println("hello this is ross speaking"); } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
pw.close();
}
PrintWriter 源码:
/* */ public PrintWriter(String paramString)
/* */ throws FileNotFoundException
/* */ {
/* 157 */ this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(paramString))), false);
/* */ }