package fileTest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class Demo1 {
public static void main(String[] args) throws IOException {
File origin = new File("F:\\javagame\\ren\\ren.txt");
File copytxt = new File("F:\\javagame\\jie\\rencopy.txt"); //定义一个读的对象
FileInputStream readTest = new FileInputStream(origin);//抛出FileNotFoundException异常
//定义一个写的对象
FileOutputStream writeTest = new FileOutputStream(copytxt);//抛出FileNotFoundException异常
int r;
while((r = readTest.read()) != -1){ //抛出IOExeception异常
writeTest.write(r); //r 为字节 一个字节一个字节的写入文档中
}
System.out.println("复制成功");
writeTest.close();
readTest.close();
}
}
/*
*一个字节一个字节读写效率低,不常用
*/