Как комментировать не знаю.
package com.javarush.task.task18.task1808;
import java.io.*;
import java.util.Scanner;
/*
Разделение файла
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream file1 = new FileInputStream(reader.readLine());
FileOutputStream file2 = new FileOutputStream(reader.readLine());
FileOutputStream file3 = new FileOutputStream(reader.readLine());
reader.close();
int length2 = 0;
int length3 = file1.available();
int size = file1.available();
if (size % 2 == 0)
length2 = size / 2;
else
length2 = Math.floorDiv(size, 2) + 1;
byte[] buff = new byte[file1.available()];
if(file1.available() > 0) {
int count = file1.read(buff);
if (count % 2 == 0) {
int half = count / 2;
int last = count - half;
file2.write(buff, 0, half);
file3.write(buff, half+1, last);
} else {
int half = Math.floorDiv(count, 2);
int last = count - half;
file2.write(buff, 0, last);
file3.write(buff, last + 1, last);
}
}
file1.close();
file2.close();
file3.close();
}
}