当前位置 : 主页 > 编程语言 > c++ >

java文件复制通用方法

来源:互联网 收集:自由互联 发布时间:2021-07-03
gistfile1.txt public static void copyFile(File fromFile,File toFile) throws IOException{ FileInputStream ins = new FileInputStream(fromFile); FileOutputStream out = new FileOutputStream(toFile); byte[] b = new byte[1024]; int n=0; while((n=
gistfile1.txt
public static void copyFile(File fromFile,File toFile) throws IOException{
	        FileInputStream ins = new FileInputStream(fromFile);
	        FileOutputStream out = new FileOutputStream(toFile);
	        byte[] b = new byte[1024];
	        int n=0;
	        while((n=ins.read(b))!=-1){
	            out.write(b, 0, b.length);
	        }
	        
	        ins.close();
	        out.close();
	    }
网友评论