Copiar el archivo de texto:
Fuente de datos: vienen
a.txt --- 读取数据----FileInputStream
Destino: Donde
b.txt---写入数据---FileOutputStream
public class test {
public static void main(String[] args) throws IOException {
//封装数据源
FileInputStream fis=new FileInputStream("2.txt");
//封装目的地
FileOutputStream fos=new FileOutputStream("b.txt");
int by;
while((by=fis.read())!=-1){
fos.write(by);//每次读取一个字节写入b.txt
}
//释放资源,顺序无关
fis.close();
fos.close();
}
}