解决方案 »

  1.   

    flush刷新缓冲区,并且注意流使用完后及时关闭
      

  2.   

    字符流都是有缓冲的!在写入输出流之后要调用flush()刷新或者close()关掉才会写入文件!
      

  3.   

    技术分没什么用的,我现在都不回答问题了;东哥哥,你怎么混起CSDN啦
      

  4.   

    没有调用flush,调用了flush才会将读取的数据推送。所以楼主在写关于io的代码时,记住一定写flush,有备无患
      

  5.   

    楼主流的资源需要被关闭。你的代码中读和写的关闭方式为:fw.close(),fr.close(),需要写在finally语句中,在finally语句中还要分别对这两句代码抓异常。写一个文件的时候调用完write方法还不够,这个时候是将写的内容保存到内存缓冲区中,需要用fw对象调用一下flush方法,但是fw对象调用了close方法后,就可以不用调用flush方法了,因为关闭流的close方法在执行时会自动调用flush刷新方法,刷新文件。
      

  6.   

    import java.io.*;class Text{
    public static void main(String args[]){
    FileInputStream fis = null;
    FileOutputStream fos = null;
    try{
    fis = new FileInputStream("e:/src/from.txt");
    fos = new FileOutputStream("e:/src/to.txt");
    byte [] buffer = new byte [1024];
    int temp = fis.read(buffer,0,buffer.length);
    fos.write(buffer,0,temp);
    }
    catch(Exception e){
    System.out.println(e);
    }
    finally{
    try{
        fis.close();
    fos.close();
    }
    catch(Exception e){
      System.out.println(e);
    }
    }
    }
    }看看这个和你的有什么不同,这个反正输出来了;但这个仅仅限于比较小的文件,如果是大的,还得加个while循环吧!楼主看看?
      

  7.   

    import java.io.*;
     
    class Text{
     public static void main(String args[]){
     FileInputStream fis = null;
     FileOutputStream fos = null;
     try{
     fis = new FileInputStream("e:/src/from.txt");
     fos = new FileOutputStream("e:/src/to.txt");
     byte [] buffer = new byte [1024];
     int temp = fis.read(buffer,0,buffer.length);
     fos.write(buffer,0,temp);
     }
     catch(Exception e){
     System.out.println(e);
     }
     finally{
     try{
         fis.close();
      }
     catch(Exception e){
       System.out.println(e);
     }
     try{
        fos.close();
     }
     catch(Exception e){
       System.out.println(e);
     } }
     }
     }
     
      

  8.   

    没使用close()关闭,开了就得关