I don;t know whats wrong with it ?
package com.codegym.task.task18.task1808;
/*
Splitting a file
*/
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
FileInputStream file1 = new FileInputStream(sc.nextLine());
FileOutputStream file2 = new FileOutputStream(sc.nextLine());
FileOutputStream file3 = new FileOutputStream(sc.nextLine());
byte[] buffer = new byte[1000];
int fileLength = 0;
try {
while (file1.available() > 0) {
fileLength = file1.read(buffer);
}
} catch (Exception e) {
} finally {
int halfLength;
if ((fileLength % 2) == 0) {
halfLength = (fileLength / 2);
} else {
halfLength = (fileLength / 2);
halfLength--;
}
int i = 0;
while (file1.available() > 0) {
if (i < halfLength) {
int b = file1.read();
file2.write(b);
} else {
int b = file1.read();
file3.write(b);
}
i++;
}
}
file1.close();
file2.close();
file3.close();
}
}