import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Democopy2 {
/**
* 一次复制一个字节数组
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//创建流对象
//读
//每次读到的字节个数
//写
//关闭流
method2();
}
public static void method2() throws IOException{
//创建流对象
FileInputStream fis = new FileInputStream("src\\dema.txt");
FileOutputStream fos = new FileOutputStream("src\\riven.txt");
//读
int len;
byte [] bytes = new byte[1024];
while((len= fis.read(bytes))!=-1){
fos.write(bytes, 0, len);
}
fis.close();
fos.close();
}
}
|
|