// 将一个二进制文件“F:\要复制的文件\name.exe”复制到D根目录
//final static int CACHE = 4096;
public static void main(String[] args) {
// 读用InputStream
try {
InputStream read = new FileInputStream("F:\要复制的文件\name.exe");// 读
OutputStream copy = new FileOutputStream("d:/name.exe");// 写到D取名if.exe
byte[] buffer = new byte[CACHE];// 缓存4k,4096
int len = 0;// 存储每次读取的字节
while ((len = read .read(buffer)) != -1) {
// 写
os.write(buffer, 0, len);
}
copy .close();
read .close();