有一道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不确定是哪个。请指教。非常感谢。
close, flush, getEncoding, write, write, write从类 java.io.Writer 继承的方法
append, append, append, write, write不确定是哪个。请指教。非常感谢。
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();
}
原题是:
Question 29
Which capability exists only in java.io.FileWriter?
A. Closing an open stream;
B. Flushing an open stream;
C. Writing to an open stream;
D. Writing a line separator to an open stream.题目中说的不是特指某个方法了,只是说有这个功能。谢谢提示。
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)