java如何利用字节流实现文件之间的相互复制

代码奉上~

public static void fileCopy(File src,File target) throws IOException {
		InputStream in = new FileInputStream(src);
		FileOutputStream out = new FileOutputStream(target);
		byte[] buffer = new byte[20 * 1024];
		while ((in.read(buffer,0,buffer.length))!=-1){
			out.write(buffer);
		}
		in.close();
		out.close();
	}
发布了39 篇原创文章 · 获赞 13 · 访问量 2323

猜你喜欢

转载自blog.csdn.net/weixin_45612794/article/details/100776802