Please i need some help. I tried it over and over again unfortunately i could not figure out.
package com.codegym.task.task18.task1808;
/*
Splitting a file
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
String file2 = reader.readLine();
String file3 = reader.readLine();
//Create a FileInputStream object bound to file1
FileInputStream inputStream = new FileInputStream(file1);
//Create a FileOutputStream object to write byte to a file2
FileOutputStream outputStream2 = new FileOutputStream(file2);
FileOutputStream outputStream3 = new FileOutputStream(file3);
int count = 0;
while (inputStream.available() > 0) {
byte[] buffer = new byte[inputStream.available()];
count = inputStream.read(buffer);
if (count % 2 != 0)
{
buffer = new byte[count];
int data = inputStream.read(buffer,0, count);
outputStream2.write(buffer, 0, data);
} else {
count = (count / 2) ;
buffer = new byte[count];
int data = inputStream.read(buffer);
outputStream3.write(buffer, 0, data);
}
}
inputStream.close();
outputStream2.close();
outputStream3.close();
}
}