public static void copyFile2(String path1, String path2) {
Reader reader = null;
Writer writer = null;
try {
// 打开流
reader = new FileReader(path1);
writer = new FileWriter(path2); // 进行拷贝
int ch = -1;
char [] arr=new char[1024];
while ((ch = reader.read(arr)) != -1) {
writer.write(arr,0,ch);
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
// 关闭流,注意一定要能执行到close()方法,所以都要放到finally代码块中
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

最新文章

  1. Windows环境安装Linux系统及JDK部署
  2. paper 117:image matting 数字抠图
  3. MySQL + Atlas --- 部署读写分离
  4. 基本概率分布Basic Concept of Probability Distributions 7: Uniform Distribution
  5. git config --global core.autocrlf false
  6. 很好的一篇讲LTP在编解码中的作用的文章
  7. 使用spring-test报异常org.springframework.asm.ClassReader.<init>(Unknown Source)
  8. sql server多表数据批量更新
  9. 惊艳的随机化方法 -World Search (homework-04)
  10. C#使用DataSet类、DataTable类、DataRow类、OleDbConnection类、OleDbDataAdapter类编写简单数据库应用
  11. oracle DBLink
  12. js中运动框架的封装
  13. 网页版仿Excel效果组件--handsontable拓展运用
  14. 三剑客之grep
  15. IIS7 配置Http重定向到Https
  16. ping -c 3 localhost
  17. GeneralizedLinearAlgorithm in Spark MLLib
  18. MVC 5使用ViewData(对象)显示数据
  19. html如何设置打印样式?
  20. spring cloud 服务提供者

热门文章

  1. hlt instruction with IF=0
  2. 【DP】区间DP入门
  3. free online linux terminal & github cli online
  4. js & replaceAll & non-global RegExp bug
  5. Azure & FaaS in Action
  6. PWA & TWA
  7. c++ 动态解析PE导出表
  8. flutter 自定义TabBar
  9. 谷歌地球服务器"失联"的替代方案
  10. m1款MacBook Air 使用3个月总结及原生运行于apple架构软件推荐