Не вижу ошибки. Помогите разобраться.🙏
package com.javarush.task.task18.task1825;
import java.io.*;
import java.util.*;
/*
Собираем файл
*/
public class Solution {
public static void main(String[] args) {
TreeMap<Integer, String> parts = new TreeMap();
String outFileNane = null;
try (InputStreamReader inputStreamReader = new InputStreamReader(System.in)) {
boolean flag = false;
while (!flag) {
String fileName = new BufferedReader(inputStreamReader).readLine();
if (fileName.equals("end")) {
inputStreamReader.close();
flag = true;
return;
}
String[] index = fileName.split(".part");
outFileNane = index[0];
parts.put(Integer.parseInt(index[1]), fileName);
}
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream outputStream = new FileOutputStream(outFileNane, true)) {
for (Map.Entry<Integer, String> vol : parts.entrySet()) {
System.out.println(vol.getValue());
try (FileInputStream inputStream = new FileInputStream(vol.getValue())) {
while (inputStream.available() > 0) {
outputStream.write(inputStream.read());
}
} catch (FileNotFoundException fileNotFoundException) {
fileNotFoundException.printStackTrace();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}