import java.io.*;
public class Test5 {
public static void main(String[] args) throws Exception {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("G:\\Demo.java"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("E:\\Demo_copy.java", true));
int len=0;
byte[] buf = new byte[1024];
while((len=bis.read(buf))!=-1) {//获得读取数据的长度len
//System.out.println(new String(buf,0,len));
bos.write(buf, 0, len); //写入存有数据的部分,空的部分不会被写进文件
bos.flush();
}
bis.close();
bos.close();
System.out.println("成功");
}
}
|