a- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class T16 {
- /**
- * 16、使用带缓冲功能的字节流复制文件。
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- BufferedInputStream bin = new BufferedInputStream(new FileInputStream("c:\\ReflectDemo2.java"));
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("F:\\copy.java"));
- byte[] bys = new byte[1024];
- int len;
- while((len=bin.read(bys))!=-1){
- bos.write(bys,0,len);
- bos.flush();
- }
- System.out.println("done");
- }
- }
复制代码
|
|