將兩個文本文件合並到一個文件中去


 1 //將兩個文本文件合並到一個文件中去
 2 package classwork10;
 3 
 4 import java.io.BufferedInputStream;
 5 import java.io.File;
 6 import java.io.FileInputStream;
 7 import java.io.IOException;
 8 import java.io.PrintWriter;
 9 
10 public class Hebing {
11 
12     public static void main(String[] args) throws IOException {
13     BufferedInputStream bf=new BufferedInputStream(new FileInputStream(new File("D:/dssjava/result1.txt")));
14     byte[] buf=new byte[bf.available()];
15     bf.read(buf);
16     BufferedInputStream bf1=new BufferedInputStream(new FileInputStream(new File("D:/dssjava/result.txt")));
17     byte[] buf1=new byte[bf1.available()];
18     bf1.read(buf1);
19     PrintWriter pw=new PrintWriter("D:/dssjava/result.txt");
20     pw.println(new String(buf)+new String(buf1));
21     bf.close();
22     bf1.close();
23     pw.close();
24     System.out.println("操作已完成");
25     }
26 
27 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM