最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

分割的文件進行合并的代碼

2020-04-05 16:39 作者:小垃圾kiki  | 我要投稿
package cn.jd.io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Copy {
?? ?public static void main(String[] args) {
?? ??? ?long t1=System.currentTimeMillis();? ?
?? ??? ?copy("如何實現(xiàn)手機和電腦的藍牙傳輸.mp4","如何實現(xiàn)手機和電腦的藍牙傳輸2.mp4");
?? ??? ?long t2=System.currentTimeMillis();//好爽就是這么塊
?? ??? ?System.out.println(t2-t1);
?? ?}

?? ?public static void copy(String srcPath, String destPath) {
?? ??? ?// 確定源
?? ??? ?//現(xiàn)在是沒有使用緩沖流
?? ??? ?File src = new File(srcPath);// 讀取的文件,使用輸入流 因為是從文件到程序
?? ??? ?File src1 = new File(destPath);// 寫入文件,輸出流,從程序到文件
?? ??? ?// 確定流
?? ??? ?//這里我是對字節(jié)流的釋放用了另一種方法
?? ??? ?try(InputStream? is=new BufferedInputStream(new FileInputStream(src));
?? ??? ??? ??? ?OutputStream? os=new BufferedOutputStream(new FileOutputStream(src1));) {
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ?byte[] flush = new byte[3];
//?? ??? ??? ??? ?System.out.println(flush.toString());???? 這里我們只是定義了,里面還沒有內(nèi)容
?? ??? ??? ?int len = -1;
?? ??? ??? ?// 確定方法
?? ??? ??? ?while ((len = is.read(flush)) != -1) { // 通過is.read讀取字節(jié)數(shù)組的長度
//?? ??? ??? ??? ??? ?System.out.println(len);
//?? ??? ??? ??? ??? ?System.out.println(flush.toString());?? //這里我不知道怎么輸出字符了
?? ??? ??? ??? ?os.write(flush, 0, len); // 將flush里面的字節(jié)寫入到文件 ,這里要輸入實際的長度
?? ??? ??? ?}
?? ??? ??? ?os.flush(); // 刷新緩沖流

?? ??? ?} catch (FileNotFoundException e) {

?? ??? ??? ?e.printStackTrace();
?? ??? ?} catch (IOException e) {
?? ??? ??? ?// TODO Auto-generated catch block
?? ??? ??? ?e.printStackTrace();
?? ??? ?}
?? ??? ?

?? ?}
}

分割的文件進行合并的代碼的評論 (共 條)

分享到微博請遵守國家法律
琼中| 青川县| 乐清市| 静乐县| 肥城市| 昔阳县| 镇宁| 西充县| 隆昌县| 锡林郭勒盟| 汶上县| 金塔县| 鄂伦春自治旗| 县级市| 新巴尔虎左旗| 子长县| 勃利县| 海安县| 盐池县| 曲周县| 龙井市| 巴里| 株洲县| 宜君县| 长子县| 江陵县| 兴城市| 修水县| 呼和浩特市| 武宁县| 读书| 余姚市| 克什克腾旗| 周宁县| 古田县| 武安市| 田阳县| 甘肃省| 乌兰县| 白朗县| 图们市|