package com . yqq . app6 ; import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . FileInputStream ; import java . io . FileOutputStream ; /** * @Author yqq * @Date 2021/11/12 22:34 * @Version 1
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* @Author yqq
* @Date 2021/11/12 22:34
* @Version 1.0
*/
public class FileCopyUtils {
public static void main(String[] args) {
copyFile("E:/pic/z2.jpg","E:/pic/z22.jpg");
}
/**
* 文件拷贝方法
*/
public static void copyFile(String src,String des){
FileInputStream fis =null;
BufferedInputStream bis = null;
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(src));
bos = new BufferedOutputStream(new FileOutputStream(des));
int temp = 0;
while((temp = bis.read())!=-1){
bos.write(temp);
bos.flush();
}
}catch (Exception e){
e.printStackTrace();
}finally {
try {
if(bis!=null){
bis.close();
}
if(fis!=null){
fis.close();
}
if(fos!=null){
fos.close();
}
if(bos!=null){
bos.close();
}
}catch (Exception e){
e.printStackTrace();
}
}
}
}