国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

用java nio合并兩個小文件的方法

2019-11-06 09:00:16
字體:
來源:轉載
供稿:網友
package com.github.elizabetht.controller;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;public class FileGathering {    public static void main(String[] args) throws IOException {        long start = System.currentTimeMillis();        File fileIn1 = new File("C://from1.txt");        File fileIn2 = new File("C://from2.txt");        File fileOut = new File("C://to.txt");        FileInputStream fin1 = new FileInputStream(fileIn1);        FileInputStream fin2 = new FileInputStream(fileIn2);        FileOutputStream fout = new FileOutputStream(fileOut);        FileChannel fcIn1 = fin1.getChannel();        FileChannel fcIn2 = fin2.getChannel();        ByteBuffer[] bufferArray = new ByteBuffer[2];        bufferArray[0] = ByteBuffer.allocate(1024);        bufferArray[1] = ByteBuffer.allocate(1024);        fcIn1.read(bufferArray[0]);        fcIn2.read(bufferArray[1]);        bufferArray[0].flip();        bufferArray[1].flip();        FileChannel fcOut = fout.getChannel();        fcOut.write(bufferArray);        long end = System.currentTimeMillis();        System.out.PRintln("time used" + (end - start));    }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汕头市| 双江| 清流县| 离岛区| 三亚市| 汽车| 句容市| 尚义县| 曲周县| 随州市| 荔浦县| 沙雅县| 庆安县| 泸溪县| 大兴区| 武安市| 十堰市| 建水县| 敦化市| 库尔勒市| 梧州市| 信阳市| 会昌县| 成安县| 合川市| 新营市| 同仁县| 昌宁县| 万年县| 乌拉特后旗| 漯河市| 清新县| 手游| 龙川县| 上蔡县| 河曲县| 孝感市| 泰顺县| 平遥县| 法库县| 庆安县|