import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TestFileInputStream {
/**
* @param args
*/
public static void main(String[] args) {
int b=0;
try{
InputStream in=new FileInputStream("F:"+File.separator+"space"+File.separator+"IOTest"+File.separator+"src"+File.separator+"TestFileInputStream.java");
//这里也可以用“//”或“\”代表windows下的文件分隔符
OutputStream out=new FileOutputStream("D://Test.java");
//文件不存在会先创建文件再写入流中的内容,文件存在直接向文件写入流中的内容。
while((b=in.read())!=-1){
out.write(b);
}
in.close();
out.close();
}catch(FileNotFoundException e){
System.out.println(e.getMessage());
System.exit(-1);
}catch(IOException e){
System.out.println(e.getMessage());
System.exit(-1);
}
System.out.println("文件复制完毕");
}
}