import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class TestClass {
public static void main(String[] args) throws IOException {
FileInputStream in = new FileInputStream(new File("F:/360Downloads/LoginAction.class"));
FileOutputStream out = new FileOutputStream(new File("F:/LoginAction.class"));
byte[] temp = new byte[1024];
while(in.read(temp)!=-1){
out.write(temp);
}
// out.flush();
in.close();
out.close();
System.out.println("---------------");
}
}
代码其实很简单,就是用java复制二进制文件。我用BCompare.exe比较一下,发现复制后的文件末尾多了一段数据,不知道是什么东西,如何保证复制前后文件二进制数据一模一样?也请解释一下采用上述代码,多出来的那段是什么东西。谢谢!