读书人

Write a line separator to an open s

发布时间: 2011-12-26 23:09:59 作者: rapoo

Write a line separator to an open stream. How and what to use? (via TranXcode)
有一道scjp的题,说java.io.FileWriter中有一个方法可以Write a line separator to an open stream。

请问下是哪个方法,有个例子最好了。

API里面看到:

从类 java.io.OutputStreamWriter 继承的方法
close, flush, getEncoding, write, write, write

从类 java.io.Writer 继承的方法
append, append, append, write, write

不确定是哪个。请指教。

非常感谢。

[解决办法]
write
[解决办法]
写程序测试一下
[解决办法]

Java code
public static void main(String[] a) throws IOException {        FileWriter fw = new FileWriter("aa.txt");        String str = System.getProperty("line.separator");        fw.write("test");        fw.write(str);        fw.write("test");        fw.close();    } 

读书人网 >J2SE开发

热点推荐