本帖最后由 香草芭芙 于 2014-10-15 03:23 编辑
- package com.itheima.day18;
- import java.io.*;
- public class FileWriterDemo3
- {
- public static void main(String[] args) throws IOException
- {
- FileWriter fw = new FileWriter("demo.txt", true);
- fw.write("abcd\r\n");
-
- FileReader fr = new FileReader("demo.txt");
-
-
- for (int ch = fr.read(); ch != -1; ch = fr.read())
- {
- System.out.print((char) ch);
- }
-
- int ch = 0;
- while ((ch = fr.read()) != -1)
- {
- System.out.print((char) ch);
- }
-
- // -------------------------------------------------
- fr.close();
- fw.close();
- }
- }
复制代码
|
|