public class demo {
public static void main(String[] args) {
try {
//通过File流实现文件的复制copy功能
FileInputStream fileIn = new FileInputStream("E:\\test\\复制样本.rar");
FileOutputStream fileOut = new FileOutputStream("E:\\test\\目标文件.rar");
byte[] b = new byte[1024];
while ((fileIn.read(b)) !=-1){
fileOut.write(b);
b=new byte[1024];
}
fileOut.close();
fileIn.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
效果图: