Не пойму где я ошибся. При тестировании в первый файл записывается только содержимое второго. public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); File fileOne = new File(reader.readLine()); File fileTwo = new File(reader.readLine()); FileInputStream fisOne = new FileInputStream(fileOne); FileInputStream fisTwo = new FileInputStream(fileTwo); FileOutputStream fosOne = new FileOutputStream(fileOne); byte[] bytesOne = new byte[fisOne.available()]; byte[] bytesTwo = new byte[fisTwo.available()]; byte[] result = new byte[fisOne.available() + fisTwo.available()]; fisOne.read(bytesOne, 0, bytesOne.length); fisTwo.read(bytesTwo, 0, bytesTwo.length); System.arraycopy(bytesTwo, 0, result, 0, bytesTwo.length); System.arraycopy(bytesOne, 0, result, bytesTwo.length, bytesOne.length); fosOne.write(result); fisOne.close(); fisTwo.close(); fosOne.close(); reader.close(); }