на первое требование не обращайте внимания! я вбил вручную для дебага!
файлы на которые записывается буфер пустые, почему?
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 string1 = reader.readLine();
// String string2 = reader.readLine();
// String string3 = reader.readLine();
// reader.close();
FileInputStream fileInputStream = new FileInputStream(new File("F:/Hobbi/Java/JavaRush/input.txt"));
FileOutputStream fileOutputStream2 = new FileOutputStream(new File("F:/Hobbi/Java/JavaRush/output1.txt"));
FileOutputStream fileOutputStream3 = new FileOutputStream(new File("F:/Hobbi/Java/JavaRush/output2.txt"));
//FileInputStream fileInputStream = new FileInputStream(string1);
// FileOutputStream fileOutputStream2 = new FileOutputStream(string2);
//FileOutputStream fileOutputStream3 = new FileOutputStream(string3);
int countByte = fileInputStream.available();
byte[] buffer = new byte[countByte];
byte[] bufferBig = new byte[(countByte / 2)+1];
byte[] bufferSmall = new byte[(countByte / 2)];
if (countByte % 2 == 0) {
int data1 = fileInputStream.read(bufferSmall);
int data2 = fileInputStream.read(buffer, bufferSmall.length-1, bufferSmall.length);
fileOutputStream2.write(data1);
fileOutputStream3.write(data2);
} else {
int data1 = fileInputStream.read(bufferBig);
int data2 = fileInputStream.read(buffer, bufferBig.length-1, bufferBig.length);
fileOutputStream2.write(data1);
fileOutputStream3.write(data2);
}
fileInputStream.close();
fileOutputStream2.close();
fileOutputStream3.close();
}
}