美文网首页
JavaSE BufferedInputDemo

JavaSE BufferedInputDemo

作者: 23b57d72cde7 | 来源:发表于2018-04-16 19:27 被阅读0次
    package com.sxt;
    
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    /**
     * 缓存字节流(处理流 包装流)
     * 
     * @author Administrator
     *
     */
    public class BufferedInputDemo {
        public static void main(String[] args) throws IOException {
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream("c:/abc.txt"));
            byte[] b = new byte[1024];
            StringBuffer sb = new StringBuffer();
            while (bis.read(b) != -1) {
                sb.append(new String(b));
            }
            System.out.println(sb);
            bis.close();
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("c:/aaa.txt"));
            bos.write("我是李四,我不怕张三".getBytes());
            bos.close();
        }
    
    }
    

    相关文章

      网友评论

          本文标题:JavaSE BufferedInputDemo

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