黑马程序员技术交流社区
标题:
使用自定义数组拷贝文件或使用高效流拷贝文件
[打印本页]
作者:
孙广浩
时间:
2015-11-14 21:31
标题:
使用自定义数组拷贝文件或使用高效流拷贝文件
package com.heima.test;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1_fileInPutStream {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//FileInputStream fis = new FileInputStream("xxx.txt"); //使用自定义数组拷贝文件
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("xxx.txt")); //使用高效流拷贝文件
//FileOutputStream fos = new FileOutputStream("copy.txt");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy.txt"));
int a ;
while ((a = bis.read()) != -1) {
bos.write(a);
}
bis.close ();
bos.close ();
}
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2