标签:int throw 存在 sts put new except read MF
1 public void copyFile(File fromFile,File toFile) throws IOException{ 2 //如果目标文件不存在,则创建 3 File parentFile = toFile.getParentFile(); 4 if(!parentFile.exists()){ 5 parentFile.mkdirs(); 6 } 7 if(!toFile.exists()){ 8 toFile.createNewFile(); 9 } 10 //复制文件 11 FileInputStream ins = new FileInputStream(fromFile); 12 FileOutputStream out = new FileOutputStream(toFile); 13 byte[] b = new byte[1024]; 14 int n=0; 15 while((n=ins.read(b))!=-1){ 16 out.write(b, 0, n); 17 } 18 19 ins.close(); 20 out.close(); 21 }
标签:int throw 存在 sts put new except read MF
原文地址:https://www.cnblogs.com/tashaxing/p/8806582.html