Программирование на Java


Example.15.5


FileInputStream inFile1 = null; FileInputStream inFile2 = null; SequenceInputStream sequenceStream = null; FileOutputStream outFile = null; try { inFile1 = new FileInputStream("file1.txt"); inFile2 = new FileInputStream("file2.txt"); sequenceStream = new SequenceInputStream(inFile1, inFile2); outFile = new FileOutputStream("file3.txt"); int readedByte = sequenceStream.read(); while(readedByte!=-1){ outFile.write(readedByte); readedByte = sequenceStream.read(); } } catch (IOException e) { System.out.println("IOException: " + e.toString()); } finally { try{sequenceStream.close();}catch(IOException e){}; try{outFile.close();}catch(IOException e){}; }

Пример 15.5.

Закрыть окно




Начало  Назад  Вперед