简单的文件复制类
来源:互联网 发布:时时彩挂机软件 编辑:程序博客网 时间:2024/05/15 08:28
package util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileUtil {
public static boolean copy(File src,File dest){
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(src));
bos = new BufferedOutputStream(new FileOutputStream(dest));
byte[] bts = new byte[1024];
int len = -1;
while((len=bis.read(bts)) != -1){
bos.write(bts,0,len);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}finally{
if(bis != null){
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(bos != null){
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileUtil {
public static boolean copy(File src,File dest){
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(src));
bos = new BufferedOutputStream(new FileOutputStream(dest));
byte[] bts = new byte[1024];
int len = -1;
while((len=bis.read(bts)) != -1){
bos.write(bts,0,len);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}finally{
if(bis != null){
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(bos != null){
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
0 0
- 简单的文件复制类
- java简单的文件复制
- 一个简单的复制文件的方法
- 简单的——文件复制
- mycopyFile_linux下实现简单文件的复制
- C/C++简单的复制文件
- java复制文件的简单方法
- java 简单的文件复制demo
- 文件复制命令CP 的简单实现
- 极客 - 博文16 - 文件的简单复制
- 复制文件目录的类
- 复制文件目录的类
- java中IO流的文件简单的复制
- java之简单的文件复制(FileStream)
- JAVA 的IO操作(五)简单文件复制
- 简单的对文件操作,如复制,读,写
- FileInputStream和FileOutputStream实现简单的文件复制
- 怎样用java写一个简单的文件复制程序
- [error handle][java script]如何做到js绑定事件的同时不执行事件
- ubuntu下进行文件编码转换(如将文件转为UTF8格式)
- iOS有关屏幕的方法大全
- 获取Android设备的方向
- OpenGL API 之 glTexImage2D
- 简单的文件复制类
- ubuntu上安装配置Ruby on Rails
- ssh框架在启动tomcat时报org.springframework.beans.factory.BeanCreationException
- android图片二次采样
- 详解ExplosionField的使用,实现View的粉碎效果
- java去除List中重复的元素
- 在Android下实现鼠标右键返回
- Linux系统文件路径映射到windows资源管理器(NFS网络文件系统)
- OpenGL API 之 glTexImage2D