如上图,输出到hello.txt中的代码怎么会有小黑点,并且不是照着源程序的格式照样输出呢?

解决方案 »

  1.   


    import java.io.*;
    public class IO2 {
      public static void main(String[] args) throws IOException {
        FileReader in=new FileReader("IO2.java");//建立文件输入流
        BufferedReader bin=new BufferedReader(in);//建立缓冲输入流
        FileWriter out=new FileWriter("Hello.txt",true);//建立文件输出流
        String str;
           while ((str=bin.readLine())!=null) {
               System.out.println(str);
               out.write(str + "\n");
        }
       in.close();
       out.close();
      }
     }
      

  2.   

    你把你输入文件的部分改成这样试一试, int b = 0;
           while ((b=bin.read())!=-1) {
            out.write(b);
        }
    因为你上面写的代码中的代码\n的用记事本解析的问题,如果是editplus打开就没问题了.