Task:
It is necessary to divide the file into 2 files exactly if in the main file there is an odd number of bytes, then in 1 file write 1 more bytes.
I just can not figure out how to make the separation so that it is recorded
public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); FileInputStream in = new FileInputStream("e:/name.txt"); FileOutputStream out = new FileOutputStream("e:/name1.txt"); FileOutputStream out2 = new FileOutputStream("e:/name2.txt"); ArrayList<Integer> list = new ArrayList<>(); while (in.available()>0){ list.add(in.read()); } int count = 0; if (list.size()%2==0) { for (int i = 0; i < list.size()/2; i++) { int data = in.read(); out.write(data); count++; } }