Не могу разобраться в чем ошибка
package com.javarush.task.task18.task1808;
import java.io.*;
/*
Разделение файла
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String firstFile = bufferedReader.readLine();
String secondFile = bufferedReader.readLine();
String thirdFile = bufferedReader.readLine();
FileInputStream fileInputStream = new FileInputStream(firstFile);
FileOutputStream secondFileOut = new FileOutputStream(secondFile);
FileOutputStream thirdFileOut = new FileOutputStream(thirdFile);
byte[] buffer = new byte[fileInputStream.available()];
for (int i = 0; i < fileInputStream.available(); i++) {
buffer[i] = (byte) fileInputStream.read();
}
int firstHalf = fileInputStream.available() / 2 + (fileInputStream.available() % 2);
int secondHalf = fileInputStream.available() - firstHalf;
secondFileOut.write(buffer, 0, firstHalf);
thirdFileOut.write(buffer,firstHalf,secondHalf);
fileInputStream.close();
secondFileOut.close();
thirdFileOut.close();
}
}