I don't understand why it's not okay, because even with my own file test it works perfectly...
package com.codegym.task.task18.task1808;
/*
Splitting a file
*/
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String file1 = sc.nextLine(), file2 = sc.nextLine(), file3 = sc.nextLine();
sc.close();
FileInputStream inputStream = new FileInputStream(file1);
FileOutputStream outputStream1 = new FileOutputStream(file2), outputStream2 = new FileOutputStream(file3);
while (inputStream.available() > 0) {
byte[] buffer = new byte[inputStream.available()];
int count = inputStream.read(buffer);
int halfCount = count / 2;
if (count % 2 != 0) {
halfCount += 1;
}
outputStream1.write(buffer, 0, halfCount);
outputStream2.write(buffer,halfCount, count-halfCount);
System.err.println(new FileInputStream(file2).available());
System.err.println(new FileInputStream(file3).available());
}
outputStream1.close();
outputStream2.close();
inputStream.close();
}
}