Собственно все работает, но валидация не проходит.. значит что то работает не так как в задании и я что то там не понимаю видимо
Создал 4 файла, /Users/levafanasov/JAVA/result.txt.partN
один /Users/levafanasov/JAVA/result.txt
проверяю - все записывается.
А валидация не проходит
package com.javarush.task.task18.task1825;
/*
Собираем файл
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
ArrayList<String> list = new ArrayList<>();
File file = new File("/Users/levafanasov/JAVA/result.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String filename = reader.readLine();
if (file.equals("end")) {
break;
}
list.add(filename);
}
for (int i = 1; i <= list.size(); i++) {
for (int j = 0; j < list.size(); j++) {
String end = ".part" + i;
if (list.get(j).endsWith(end)) {
Reader.inicializeReader(list.get(j), file);
}
}
}
}
public static class Reader {
public static void inicializeReader(String path, File file) throws IOException {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(path));
FileOutputStream outputStream = new FileOutputStream(file, true);
byte[] buffer = new byte[4096];
int count = bufferedInputStream.read(buffer);
outputStream.write(buffer, 0, count);
outputStream.close();
bufferedInputStream.close();
}
}
}