将两个文本文件合并到一个文件中去


 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