复制操作代码实现流程
public static void copyFile(File srcFile,File destFile)throws IOException{ if(!srcFile.exists()){ throw new IllegalArgumentException("文件:"+srcFile+"不存在"); } if(!srcFile.isFile()){ throw new IllegalArgumentException(srcFile+"不是文件"); } FileInputStream in = new FileInputStream(srcFile); FileOutputStream out = new FileOutputStream(destFile); byte[] buf = new byte[8*1024]; int b; while((b=in.read(buf,0,buf.length))!=-1){ out.write(buf,0,b); out.flush(); } in.close(); out.close(); }
谁能帮我讲一下这个是如何从srcFile中读取之后写到destFile中去的呢,我只看到了读的操作,写操作不是写到buf数组里了吗