美文网首页
字符读取流缓冲区

字符读取流缓冲区

作者: 实在想不出昵称丶 | 来源:发表于2017-01-06 23:00 被阅读0次

    January201703



    /**
    字符读取流缓冲区
    */
    import java.io.*;
    public class Test{
      public static void main(String[] args) throws IOException{
        BufferedReader bufr=null;
        BufferedWriter bufw=null;
        try{
          bufr=new BufferedReader(new FileReader("index.html"));
          bufw=new BufferedWriter(new FileWriter("test.txt"));
          String line=null;
          while((line=bufr.readLine())!=null){
            bufw.write(line);
            bufw.newLine();
            bufw.flush();
          }
        }
        catch(IOException e){
          throw new RuntimeException("读写失败");
        }
        finally{
          try{
            if(bufr !=null)
               bufr.close();
          }
          catch(IOException e){
            throw new RuntimeException("读取关闭失败");
          }
          try{
            if(bufw!=null)
               bufw.close();
          }
          catch(IOException e){
            throw new RuntimeException("x写入关闭失败");
          }
        }
      }
    }
    
    

    *** 清醒小刻 ***
    *** 没错,我说的都是错的!!***


    相关文章

      网友评论

          本文标题:字符读取流缓冲区

          本文链接:https://www.haomeiwen.com/subject/tcixbttx.html