java实现图片等文件类型的本地复制
由于很简单直接上代码
package demo; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; public class PicIo { public static void main(String[] args) { String src="D://FILESERVER//IMGNFS//estun_cs//staff_family_file//1508985399735.jpg"; String target="D://FILESERVER//IMGNFS//estun_cs//banner_img//1508985399735.jpg"; try { copyFile(src,target); } catch (Exception e) { e.printStackTrace(); } } public static void copyFile(String src,String target) throws Exception { File srcFile = new File(src); File targetFile = new File(target); InputStream in = new FileInputStream(srcFile); OutputStream out = new FileOutputStream(targetFile); byte[] bytes = new byte[1024]; int len = -1; while((len=in.read(bytes))!=-1){ out.write(bytes, 0, len); } in.close(); out.close(); } }
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/13899.html