A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 薛灵云 中级黑马   /  2015-8-28 09:12  /  671 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

package com.itheima;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

//使用带缓冲功能的字节流复制文件。
public class ExamTest16 {
        public static void main(String[] args) {
                BufferedInputStream bis = null;
                BufferedOutputStream bos = null;
                try {
                        bis = new BufferedInputStream(new FileInputStream("a.txt"));
                        bos = new BufferedOutputStream(new FileOutputStream("copya.txt"));

                        byte[] bys = new byte[1024];
                        int len = 0;
                        while ((len = bis.read(bys)) != -1) {
                                bos.write(bys, 0, len);
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        try {
                                bos.close();
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
                        try {
                                bis.close();
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
                }
        }
}


1 个回复

倒序浏览
帮顶一下~~~~~~~~~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马