В чем проблема?
package com.javarush.task.task18.task1819;
/*
Объединение файлов
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
byte[] buffer1 = new byte[0];
byte[] buffer2 = new byte[0];
String fileName1 = reader.readLine();
FileInputStream fileInputStream1 = new FileInputStream(fileName1);
String fileName2 = reader.readLine();
FileInputStream fileInputStream2 = new FileInputStream(fileName2);
while (fileInputStream1.available()>0){
buffer1 = new byte[fileInputStream1.available()];
int count = fileInputStream1.read(buffer1);
fileInputStream1.close();
}
while (fileInputStream2.available()>0){
buffer2 = new byte[fileInputStream2.available()];
int count1 = fileInputStream2.read(buffer2);
}
fileInputStream2.close();
FileOutputStream fileOutputStream = new FileOutputStream(fileName1);
fileOutputStream.write(buffer2);
fileOutputStream.write(buffer1);
fileOutputStream.close();
reader.close();
}
}