阅读背景:

java io流实现拷贝文件

来源:互联网 
public void test4() throws Exception {
		// 1:读取文件
		InputStream in = new FileInputStream("e:/dmx1.mp4");
		// 2:写一个文件
		OutputStream out = new FileOutputStream("d:/a/a.mp4");
		// 3:开始读写文件
		byte[] bs = new byte[1024];  //一次文件中读取1024个字节,如果文件中少于1024个字节,则就读取<1024节字,返回读取到的节的数量,如果文件中大于1024个字节
		int len = 0;
		while ((len = in.read(bs)) != -1) {
			out.write(bs, 0, len);
		}
		in.close();
		out.close();
	}
public void test4() throws Exception {
		// 1:读



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: