es ist deprimierend, was ist der fehler?
package de.codegym.task.task18.task1808;
/*
Eine Datei teilen
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
File file1 = new File(reader.readLine());
File file2 = new File(reader.readLine());
File file3 = new File(reader.readLine());
FileInputStream inStream = new FileInputStream(file1);
FileOutputStream outStream1 = new FileOutputStream(file2); //outStream1 = bigger part
FileOutputStream outStream2 = new FileOutputStream(file3);
if(file1.length() % 2 == 0){
while(inStream.available() > 0){
byte[] buff1 = new byte[(int)file1.length() / 2];
int data1 = inStream.read(buff1);
outStream2.write(buff1, 0, data1);//outStream2 writes in file3
byte[] buff2 = new byte[(int)file1.length() / 2 + 1];
int data2 = inStream.read(buff2);
outStream1.write(buff2, 0, data2); //bigger part on outStream1 write in file2
}
}
else if(file1.length() % 2 != 0){
while(inStream.available() > 0){
byte[] buff1 = new byte[(int)file1.length() / 2 + 1];// same but diffrent
int data1 = inStream.read(buff1);
outStream2.write(buff1, 0, data1);//bigger part into stream2, so in file3
byte[] buff2 = new byte[(int)file1.length() / 2];
int data2 = inStream.read(buff2);
outStream1.write(buff2, 0, data2); //small in file2
}
}
inStream.close();
outStream1.close();
outStream2.close();
}
}