UPD: Ахтунг, все что написано ниже не правильно. см коменты
Вроде все как записывает, но что то, не то.
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream fis = new FileInputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\First.txt"
FileOutputStream fileOutputStreamSecond = new FileOutputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\Second.txt"
FileOutputStream fileOutputStreamThird = new FileOutputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\Third.txt"
while (fis.available() > 0){
String stringOfByte = Integer.toString(fis.read());
int count = stringOfByte.length();
int i = 0;
while (count > 0){
fileOutputStreamSecond.write(Integer.parseInt(stringOfByte.substring(i, i+1)));
count--;
i++;
if(count == 0) break;
else fileOutputStreamThird.write(Integer.parseInt(stringOfByte.substring(i, i+1)));
}
}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));
FileInputStream fis = new FileInputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\First.txt"
FileOutputStream fileOutputStreamSecond = new FileOutputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\Second.txt"
FileOutputStream fileOutputStreamThird = new FileOutputStream(reader.readLine());//"D:\\SQL and JAVA\\JAVA\\txtFiles\\Third.txt"
while (fis.available() > 0){
String stringOfByte = Integer.toString(fis.read());
int count = stringOfByte.length();
int i = 0;
/* System.out.print(stringOfByte + " ");
System.out.println(count + " ");*/
while (count > 0){
fileOutputStreamSecond.write(stringOfByte.charAt(i));
// fileOutputStreamSecond.write(Integer.parseInt(stringOfByte.substring(i, i+1)));
count--;
i++;
if(count == 0) break;
else fileOutputStreamThird.write(stringOfByte.charAt(i));//fileOutputStreamThird.write(Integer.parseInt(stringOfByte.substring(i, i+1)));
}
//for (int i = 0; i < count; i++){
//fileOutputStreamThird.write(Integer.parseInt(stringOfByte.substring(0, count)));
//}
//for (int i = count; i < stringOfByte.length(); i++){
// fileOutputStreamSecond.write(Integer.parseInt(stringOfByte.substring(count)));
//}
}
reader.close();
fis.close();
fileOutputStreamSecond.close();
fileOutputStreamThird.close();
}
}