麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

IO流_字節流四種方式復制MP4并測試效率

2019-11-10 19:20:55
字體:
來源:轉載
供稿:網友
package cn.itcast_06;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;/* * 需求:把e://哥有老婆.mp4復制到當前項目目錄下的copy.mp4中 *  * 哥有老婆.mp4文件大小:65,258,338 字節 * 字節流四種方法復制文件: * 		基本字節流一次讀寫一個字節:共耗時:607844毫秒(607.844秒=10多分鐘) * 		基本字節流一次讀寫一個字節數組:共耗時:1042毫秒(1.042秒) * 		高效字節流一次讀寫一個字節:共耗時:5575毫秒(5.575秒) * 		高效字節流一次讀寫一個字節數組:共耗時:535毫秒(0.535秒) */public class CopyMp4Demo {	public static void main(String[] args) throws IOException {		long start = System.currentTimeMillis();		method1("e://哥有老婆.mp4", "copy1.mp4");		// method2("e://哥有老婆.mp4", "copy2.mp4");		// method3("e://哥有老婆.mp4", "copy3.mp4");		// method4("e://哥有老婆.mp4", "copy4.mp4");		long end = System.currentTimeMillis();		System.out.PRintln("共耗時:" + (end - start) + "毫秒");	}	/**	 * 基本字節流一次讀寫一個字節	 * 	 * @param srcString	 *            數據源	 * @param destString	 *            目的地	 */	public static void method1(String srcString, String destString)			throws IOException {		// 封裝數據源		FileInputStream fis = new FileInputStream(srcString);		// 封裝目的地		FileOutputStream fos = new FileOutputStream(destString);		// 復制數據		int len = 0;		while ((len = fis.read()) != -1) {			fos.write(len);		}		// 釋放資源		fos.close();		fis.close();	}	/**	 * 基本字節流一次讀寫一個字節數組	 * 	 * @param srcString	 *            數據源	 * @param destString	 *            目的地	 */	public static void method2(String srcString, String destString)			throws IOException {		// 封裝數據源		FileInputStream fis = new FileInputStream(srcString);		// 封裝目的地		FileOutputStream fos = new FileOutputStream(destString);		// 復制數據		byte[] bys = new byte[1024];		int len = 0;		while ((len = fis.read(bys)) != -1) {			fos.write(bys, 0, len);		}		// 釋放資源		fos.close();		fis.close();	}	/**	 * 高效字節流一次讀寫一個字節	 * 	 * @param srcString	 *            數據源	 * @param destString	 *            目的地	 */	public static void method3(String srcString, String destString)			throws IOException {		// 封裝數據源		BufferedInputStream bis = new BufferedInputStream(new FileInputStream(				srcString));		// 封裝目的地		BufferedOutputStream bos = new BufferedOutputStream(				new FileOutputStream(destString));		// 復制數據		int len = 0;		while ((len = bis.read()) != -1) {			bos.write(len);		}		// 釋放資源		bos.close();		bis.close();	}	/**	 * 高效字節流一次讀寫一個字節數組	 * 	 * @param srcString	 *            數據源	 * @param destString	 *            目的地	 */	public static void method4(String srcString, String destString)			throws IOException {		// 封裝數據源		BufferedInputStream bis = new BufferedInputStream(new FileInputStream(				srcString));		// 封裝目的地		BufferedOutputStream bos = new BufferedOutputStream(				new FileOutputStream(destString));		// 復制數據		byte[] bys = new byte[1024];		int len = 0;		while ((len = bis.read(bys)) != -1) {			bos.write(bys, 0, len);		}		// 釋放資源		bos.close();		bis.close();	}}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 一本色道精品久久一区二区三区 | 毛片福利 | chinese18 xxxx videos| 亚洲国产精品高潮呻吟久久 | 久久蜜桃香蕉精品一区二区三区 | 黄色免费在线视频网站 | 久久久精品视频免费 | 毛片视频在线免费观看 | 成人福利在线看 | 国产一国产一级毛片视频在线 | 亚洲人成中文字幕在线观看 | 欧美成在人线a免费 | 最新中文字幕在线 | 亚洲涩涩图 | 一级电影在线免费观看 | 国产日韩在线观看一区 | 福利在线播放 | 久久久久亚洲精品国产 | 国产精品自拍啪啪 | 欧美女同hd | 九一成人 | 国产91在线亚洲 | 有色视频在线观看 | 91精品国产网站 | 国产一级免费在线视频 | 久久国产精品影视 | 特级毛片免费视频 | 精品在线一区二区三区 | 欧美激情999| 摸逼逼视频 | 日韩一级免费毛片 | 天天看天天摸天天操 | 国产精品午夜小视频观看 | 国产精品久久久久久久久久电影 | 免费黄色在线 | 黄网站在线观 | 国产亚洲精品影达达兔 | 日韩色电影 | 国产免费观看一区二区三区 | 91成人免费看片 | 久久精品伊人网 |