使用流复制二进制文件
import java.io.FileInputStream; import java.io.FileNotFoundException; /* from 时 代 J a v a - N o w J a v a . c o m */ import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void main(String[] args) { String strSourceFile = "C:/Folder/source.dat"; String strDestinationFile = "C:/Folder/dest.dat"; /** nowjava - 时代Java 提 供 **/ try { FileInputStream fin = new FileInputStream(strSourceFile); FileOutputStream fout = new FileOutputStream(strDestinationFile); byte[] b = new byte[1024]; int noOfBytes = 0; while ((noOfBytes = fin.read(b)) != -1) { fout.write(b, 0, noOfBytes); } System.out.println("File copied!"); fin.close(); fout.close(); } catch (FileNotFoundException fnf) {