使用FileInputStream和FileOutputStream逐字节复制文件
import java.io.FileInputStream;/* 来自 nowjava.com - 时代Java*/ import java.io.FileOutputStream; import java.io.IOException; public class CopyBytes { public static void main(String[] args) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream("xanadu.txt"); out = new FileOutputStream("outagain.txt"); int c; /** N o w J a v a . c o m - 时代Java 提 供 **/ while ((c = in.read()) != -1) { out.write(c); } } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }