Buffered字节处理流拷贝文件
public class BufferedCopy02 {
public static void main(String[] args) {
String srcFilePath = "D:\\Chou.jpg";
String destFilePath = "D:\\Chou2.jpg";
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
byte[] buff = new byte[1024];
int readLen = 0;
try {
bis = new BufferedInputStream(new FileInputStream(srcFilePath));
bos = new BufferedOutputStream(new FileOutputStream(destFilePath));
while ((readLen = bis.read(buff)) != -1){
bos.write(buff,0,readLen);
}
System.out.println("拷贝成功!");
} catch (Exception e) {
e.printStackTrace();
}finally {
if (bis != null){
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (bos != null){
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}