public static void copy(String srcPath,String desPath) throws IOException {
File srcFile = new File(srcPath);
File desFile = new File(desPath);
if(desFile.exists()){
desFile.delete();
}
desFile.createNewFile();
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(srcFile));
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(desFile));
byte[] bytes= new byte[1024];
int length = 0 ;
while ((length = bufferedInputStream.read(bytes,0,bytes.length)) != -1){
bufferedOutputStream.write(bytes,0,bytes.length);
bufferedOutputStream.flush();
}
bufferedInputStream.close();
bufferedOutputStream.close();
}
理论上 byte 值越大越快