Программа работает, как положено, проверяла и размеры файлов, и содержимое файлов, но валидатор не пускает.
Многие решили задачу через буфер, поместив туда сразу весь размер файла, решила так не делать, мало ли, какой размер файла может быть. Но почему мой метод не проходит валидатором?
package com.javarush.task.task18.task1808;
/*
Разделение файла
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String nameOne = reader.readLine();
String nameTwo = reader.readLine();
String nameThree = reader.readLine();
File fileOne = new File(nameOne);
File fileTw = new File(nameTwo);
File fileTr = new File(nameThree);
FileInputStream fileInputStream = new FileInputStream(fileOne);
FileOutputStream fileOutputStream = new FileOutputStream(nameTwo);
FileOutputStream fileOutputStreamTwo = new FileOutputStream(nameThree);
if (fileOne.length() % 2 != 0) {
while (fileInputStream.available() >= ((fileOne.length() / 2)) + 1){
int a = fileInputStream.read();
fileOutputStream.write(a);
}
while (fileInputStream.available() > 0){
int a = fileInputStream.read();
fileOutputStreamTwo.write(a);
}
}else{
while (fileInputStream.available() > fileOne.length() / 2) {
int a = fileInputStream.read();
fileOutputStream.write(a);
}
while (fileInputStream.available() > 0){
int a = fileInputStream.read();
fileOutputStreamTwo.write(a);
}
}
fileInputStream.close();
fileOutputStream.close();
fileOutputStreamTwo.close();
System.out.println(fileOne.length() + " " + fileTw.length() + " " + fileTr.length());
}
}