//这是你的源文件,本身是存在的
File beforefile = new File("c://a.txt");

//这是你要保存之后的文件,是自定义的,本身不存在
File afterfile = new File("d://a.txt");

//定义文件输入流,用来读取beforefile文件
InputStream in = new FileInputStream(beforefile);

//定义文件输出流,用来把信息写入afterfile文件中
OutputStream out = new FileOutputStream(afterfile);

//文件缓存区
byte[] bytes= new byte[1024];
//将文件流信息读取文件缓存区,如果读取结果不为-1就代表文件没有读取完毕,反之已经读取完毕
while(in.read( bytes )!=-1){
//将缓存区中的内容写到afterfile文件中
out.write( bytes );
out.flush();

out.close();
}

相关文章:

  • 2022-12-23
  • 2021-07-05
  • 2021-10-26
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-11-12
猜你喜欢
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-10-07
  • 2021-11-05
  • 2021-08-10
相关资源
相似解决方案