//public class Solution { // public static void main(String[] args) throws IOException { // BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // String file1 = reader.readLine(); // String file2 = reader.readLine(); // FileInputStream fileReader1 = new FileInputStream(file1); // FileInputStream fileReader2 = new FileInputStream(file2); // FileOutputStream fielOut1 = new FileOutputStream(file1); // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); // // while (fileReader2.available()>0){ // byteArrayOutputStream.write(fileReader2.read()); // } // fileReader2.close(); // while (fileReader1.available()>0){ // byteArrayOutputStream.write(fileReader1.read()); // } // fileReader1.close(); // byteArrayOutputStream.writeTo(fielOut1); // fielOut1.close(); // } //} public class Solution { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String fileName1 = reader.readLine(); String fileName2 = reader.readLine(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (FileInputStream fileInputStream1 = new FileInputStream(fileName1); FileInputStream fileInputStream2 = new FileInputStream(fileName2)) { while (fileInputStream2.available() > 0) { byteArrayOutputStream.write(fileInputStream2.read()); } while (fileInputStream1.available() > 0) { byteArrayOutputStream.write(fileInputStream1.read()); } } try (FileOutputStream fileOutputStream = new FileOutputStream(fileName1)) { byteArrayOutputStream.writeTo(fileOutputStream); } } }