解决方案 »

  1.   

    public FileWriter(String fileName,boolean append) throws IOException
    这是FileWriter的另一个构造函数
    append - boolean if true, then data will be written to the end of the file rather than the beginning.
    append参数表示如果为true则在文件末尾写!如果为false则在文件开头写!
    默认append为false!第一种当创建了输入流就读出了数据!当创建输出流时文件内容被置为空,因为append为false;
    第二种创建了输出流后接着创建输出流,此时文件已经为空了!再读出的数据就为空!建议楼主:  既然都用PrintWriter了为什么不直接用println方法!
      

  2.   

    当然被清空了啊!但是数据已经读到了输入流里了!BufferedReader会有缓存的!