public static void main(String[] args) {//声明两个文件读入流FileInputStream in1 = null,in2 = null;//声明一个序列流SequenceInputStream s = null;//声明一个输出流FileOutputStream out = null;try {//构造两个被读入的文件File inputFile1 = new File("d:\\1.txt");File inputFile2 = new File("d:\\2.txt");//构造一个输出文件File outputFile = new File("d:\\1and2.txt");in1 = new FileInputStream(inputFile1);in2 = new FileInputStream(inputFile2);//将两个输入流合为一个输入流s = new SequenceInputStream(in1,in2);out = new FileOutputStream(outputFile);int c;while((c = s.read())!=-1) {out.write(c);}in1.close();in2.close();s.close();System.out.println("ok....");}catch(IOException e) {e.printStackTrace();}}
添加回答
举报
0/150
提交
取消