java 使用字节流拷贝文件
import java.io.*;
public class BufferCopyTest2 {
public static void copyFile(String filePath, String copyFilePath) throws IOException {
BufferedInputStream inputStream = null;
BufferedOutputStream outputStream = null;
inputStream = new BufferedInputStream(new FileInputStream(filePath));
outputStream = new BufferedOutputStream(new FileOutputStream(copyFilePath));
byte[] bytes = new byte[1024];
int line = 0;
while ((line = inputStream.read(bytes)) != -1){
outputStream.write(bytes,0,line);
}
inputStream.close();
outputStream.close();
System.out.println("拷贝完成");
}
public static void main(String[] args) throws IOException {
String filePath = "D:/upload1457887643252563969.wav";
String copyFilePath = "D:/result1.wav";
copyFile(filePath,copyFilePath);
}
}