BufferedInputStream/BufferedOutputStream复制文件
public class Test{
public static void main(String[] args) throws IOException{
FileInputStream in = null;
BufferedInputStream bis =null;
FileOutputStream out =null;
BufferedOutputStream bos =null;
try {
in=new FileInputStream("c:/123/666.doc");
bis=new BufferedInputStream(in);
out=new FileOutputStream("c:/123/999.doc");
bos = new BufferedOutputStream(out);
int len =0;
byte[] buffer = new byte[1024];
while((len=bis.read(buffer))!=-1){
bos.write(buffer, 0, len);
// bos.write(buffer);
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
bos.flush(); //清空缓存写入数据
bos.close(); //一定要关闭流否则文档打开不了
out.close();
bis.close();
in.close();
}
}
最新文章
- 在 Delphi 中判断一个字符是中文的方法
- Windows 10 安装双系统 CentOS 7
- App开发三种模式
- CSS应用心得
- hdu 1054 最小点覆盖
- HDU1002 -A + B Problem II(大数a+b)
- 深入理解计算机系统第二版习题解答CSAPP 2.3
- java获取天气信息
- 何时可以开启透明数据加密(TDE)?
- JavaWEB HTTP请求中POST与GET的区别
- Elasticsearch常用插件(三)
- swig官方go Examples 源码勘误
- tomcat环境配置 Linux 与 Windows
- debian The type initializer for 'System.Drawing.KnownColors' threw an exception
- 小程序git发布
- LVS搭建负载均衡(二)DR模型
- git初始化本地项目并推送到git服务器
- python 美化打印json数据
- Django 前台通过json 取出后台数据
- 【TP3.2.X】linux环境下TP3.2.X的各个目录权限