it work locally...
package fr.codegym.task.task18.task1825;
import java.io.*;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
/*
Création d'un fichier
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
String filename = console.readLine();
String targetFile = filename.substring(0, filename.indexOf(".part"));
//this treemap is sorted by filename and store each chunk of byte[]
//TreeMap keep keys ordered :-)
SortedMap<String, byte[]> fileChunks = new TreeMap<>();
//read all 3.part<n> files and store theire content in the fileChunks treemap
while (filename.equals("fin") == false) {
InputStream input = new FileInputStream(filename);
byte[] buffer = new byte[input.available()];
input.read(buffer);
input.close();
fileChunks.put(filename, buffer);
filename = console.readLine();
}
OutputStream finalFile = new FileOutputStream(targetFile);
//write fileChunks in the right order
for (Map.Entry<String, byte[]> chunk : fileChunks.entrySet()) {
finalFile.write(chunk.getValue(), 0 , chunk.getValue().length);
}
finalFile.flush();
finalFile.close();
console.close();
}
}