本帖最后由 黄锐 于 2012-7-19 22:10 编辑
- <P>
- 写代码中遇到一个问题?
- public class BufferedWriterDemo {</P>
- <P> public static void main(String[] args) throws IOException {
- FileWriter fw = new FileWriter("demo.txt");
- BufferedWriter bw = new BufferedWriter(fw);</P>
- <P> bw.write("haha");
- bw.write("\r\n");//<FONT color=red>这样换行不好.
- </FONT> bw.newLine();
- bw.write("hellojava");
- bw.newLine();</P>
- <P> for (int x = 0; x < 4; x++) {
- bw.write("java" + x);
- bw.newLine();
- // if (x % 2 == 0) {
- // bw.flush();
- // }
- }</P>
- <P> bw.close();
- // fw.close(); <FONT color=red>这里还用关闭流吗?
- </FONT> }</P>
- <P>}</P>
复制代码 |
|