Can someone help me with this ?
Everything works fine on my computer but this won't pass.
package fr.codegym.task.task18.task1825;
import java.io.*;
import java.util.TreeSet;
/*
Création d'un fichier
*/
public class Solution {
public static void main(String[] args) {
final TreeSet <File> filePartsTreeSet = new TreeSet <>((o1, o2) -> {
String[] parts1 = (o1.toString()).split(".part");
String[] parts2 = (o2.toString()).split(".part");
int number1 = Integer.parseInt(parts1[parts1.length - 1]);
int number2 = Integer.parseInt(parts2[parts2.length - 1]);
return number1 - number2;
});
String[] newFileName = new String[1];
try (BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in))) {
String filePath;
while (!(filePath = consoleReader.readLine()).equals("end")) {
File filePart = new File(filePath);
filePartsTreeSet.add(filePart);
// Getting the name of the file to be created.
if (newFileName[0] == null) {
newFileName = filePath.split(".part");
}
}
// Creating a new file.
File newFile = new File(newFileName[0]);
// Adding everything to the new file in order.
for (File fileParts : filePartsTreeSet) {
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(fileParts)); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(newFile, true))) {
while (bufferedInputStream.available() > 0) {
bufferedOutputStream.write(bufferedInputStream.read());
}
}
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}