使用Java怎么將多個(gè)文檔合并輸出到一個(gè)文檔-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)使用Java怎么將多個(gè)文檔合并輸出到一個(gè)文檔,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

成都創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),額濟(jì)納企業(yè)網(wǎng)站建設(shè),額濟(jì)納品牌網(wǎng)站建設(shè),網(wǎng)站定制,額濟(jì)納網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,額濟(jì)納網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

方法:Java NIO

package First;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;

public class Test {

  
  public static void main(String params[]) throws Exception {
    String[] iF = new String[] {"E:/test1.txt", "E:/test2.txt", "E:/test3.txt", "E:/test4.txt" };
    String oF = "E:/out.txt";
    
    FileOutputStream output = new FileOutputStream(new File(oF));
    WritableByteChannel targetChannel = output.getChannel();
    
    for(int i =0; i<iF.length; i++){
      FileInputStream input = new FileInputStream(iF[i]);
      FileChannel inputChannel = input.getChannel();
      
      inputChannel.transferTo(0, inputChannel.size(), targetChannel);
      
      inputChannel.close();
      input.close();
    }
    targetChannel.close();
    output.close();
    System.out.println("All jobs done...");
    
  }


  
}

關(guān)于使用Java怎么將多個(gè)文檔合并輸出到一個(gè)文檔就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

分享文章:使用Java怎么將多個(gè)文檔合并輸出到一個(gè)文檔-創(chuàng)新互聯(lián)
本文路徑:http://muchs.cn/article6/dcpeig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、微信小程序、虛擬主機(jī)、網(wǎng)站改版網(wǎng)站制作、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)