字节流简单文件复制

@Test
public void FileInput() throws IOException {
File file = new File("a.txt");    //源,可用路径地址代替 文件格式任意
FileInputStream fileInputStream = new FileInputStream(file);
FileOutputStream fileOutputStream = new FileOutputStream("b.txt");    //复制后文件保存地址,默认在工程目录下
byte[] bytes= new byte[1024];    //缓冲容器
int len;
while ((len = fileInputStream.read(bytes))!=-1){
fileOutputStream.write(bytes,0,len);
}
fileInputStream.close();
fileOutputStream.close();
}
posted @ 2020-10-20 15:45  今夜明珠色  阅读(116)  评论(0编辑  收藏  举报