в тесте выдает исключение java.lang.IndexOutOfBoundsException
направьте на путь истинный
package com.javarush.task.task18.task1808;
import java.io.*;
/*
Разделение файла
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader fileNames = new BufferedReader(new InputStreamReader(System.in));
String file1 = fileNames.readLine();
String file2 = fileNames.readLine();
String file3 = fileNames.readLine();
try(FileInputStream fileInputStream = new FileInputStream(file1);
FileOutputStream fileOutputStream1 = new FileOutputStream(file2);
FileOutputStream fileOutputStream2 = new FileOutputStream(file3)){
byte[] buffer = new byte[fileInputStream.available()];
int countBytes = fileInputStream.read(buffer);
if (countBytes % 2 == 0) {
fileOutputStream1.write(buffer, 0, countBytes / 2);
fileOutputStream2.write(buffer, countBytes / 2 + 1, countBytes);
} else {
fileOutputStream1.write(buffer, 0, (countBytes + 1) / 2);
fileOutputStream2.write(buffer, (countBytes - 1) / 2, countBytes);
}
}
catch (Exception e){
e.printStackTrace();
}
}
}
ты записываешь один и тот же массив, с чего ты взял что он будет сам делиться на половины?