It is necessary to read data from two streams and write to one.
FileOutputStream file1 = new FileOutputStream("D:\\file1.txt"); SequenceInputStream sequance = new SequenceInputStream(new FileInputStream("D:\\file3.txt"), new FileInputStream("D:\\file2.txt")); int size = sequance.available(); int reading = 0; byte[] buffer = new byte[size]; if(sequance.available() > 0) { reading = sequance.read(buffer, 0, size); file1.write(buffer, 0, reading); } sequance.close(); file1.close(); } catch (IOException ex){ex.printStackTrace();} Reads only from the first stream, if the threads in the constructor are reversed, then again reads only from the first stream (in the resulting file, the data only from the first stream made debug, the size variable is equal to the number of characters in the first stream). Where is the mistake?