It seems to work perfectly when I test it.
-Reads file names until the String end is entered.
-Creates multiple different names for files and gives each name a different .part number.
-Creates the actual files
-Then writes each file's bytes/contents to the Main file.
It will create the files and add all their contents to the main file without the part.
I failed verification 2-5
package com.codegym.task.task18.task1825;
import java.io.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
/*
Building a file
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringBuilder fileName = new StringBuilder(reader.readLine());
File dest = new File("C:\\Users\\jaypa\\Documents\\Codegym\\CodeGymTasks\\2.JavaCore\\src\\com\\codegym\\task\\task18\\task1825\\Lion.avi");
ArrayList<File> list = new ArrayList<>();
int N = 1;
while (!fileName.toString().equals("end")) {
fileName.append(".part").append(N);
N++;
File file = new File("C:\\Users\\jaypa\\Documents\\Codegym\\CodeGymTasks\\2.JavaCore\\src\\com\\codegym\\task\\task18\\task1825\\" + fileName);
list.add(file);
fileName = new StringBuilder(reader.readLine());
}
for (File x : list) {
x.createNewFile();
}
for (File file : list) {
try (BufferedReader reader2 = new BufferedReader(new FileReader(file)); BufferedWriter writer = new BufferedWriter(new FileWriter(dest, true))) {
while (reader2.ready()) {
String data = reader2.readLine();
writer.write(data);
}
}
}
}
}