The output is correct but fail condition 2 and 3.
package com.codegym.task.task18.task1808;
/*
Splitting a file
*/
import java.io.*;
import java.util.ArrayList;
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();
String file3 = reader.readLine();
FileInputStream fileName1 = new FileInputStream(file1);
FileOutputStream fileName2 = new FileOutputStream(file2);
FileOutputStream fileName3 = new FileOutputStream(file3);
byte[] buffer = new byte[fileName1.available()];
while(fileName1.available() > 0){
int count = fileName1.read(buffer);
int mid = count % 2 == 0 ? count / 2 : (count + 1 ) / 2 ;
fileName2.write(buffer, 0, mid);
fileName3.write(buffer, (mid + 1), count);
}
reader.close();
fileName1.close();
fileName2.close();
fileName3.close();
}
}