I can't pass any test...
package com.codegym.task.task18.task1825;
import java.io.*;
import java.util.*;
/*
Building a file
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
Map<Integer, String> parts = new HashMap<>();
String name, shortName = "";
while (!(name = console.readLine()).equals("end")) {
int endpoint = name.indexOf(".part");
int index = Integer.parseInt(name.substring(endpoint + 5, name.length() - 1));
parts.put(index, name);
if (shortName.isEmpty()) { shortName = name.substring(0, index); }
}
console.close();
if (!parts.isEmpty()) {
FileOutputStream fileOutputStream = new FileOutputStream(shortName);
for (int index = 1; index < parts.size() + 1; index ++) {
FileInputStream fileInputStream = new FileInputStream(parts.get(index));
byte[] buffer = new byte[fileInputStream.available()];
fileInputStream.read(buffer);
fileInputStream.close();
fileOutputStream.write(buffer);
}
fileOutputStream.close();
}
}
}