Вроде проверил на тестовых файлах он собирает норм
Но на avi не пробовал байты что ли теряются?
Спасибо
package com.javarush.task.task18.task1825;
import java.io.*;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
/*
Собираем файл
*/
public class Solution {
public static void main(String[] args) throws IOException {
String s;
TreeSet<String> name = new TreeSet<>();
BufferedReader reader = new BufferedReader( new InputStreamReader(System.in));
int x=0;
String firstPartName="";
while (true)
{
s= reader.readLine();
// firstPartName= "4.txt.part1";
// name.add("4.txt.part1");
// name.add("4.txt.part2");
// name.add("4.txt.part3");
// s="end";
// x=1;
if (x==0){
x=1;
firstPartName=s;
}
if (s.equals("end")) break;
name.add(s);
}
int index1 = firstPartName.indexOf(".part1");
firstPartName = firstPartName.substring(0,index1);
// System.out.println(firstPartName);
// Создаем поток-записи-байт-в-файл
FileOutputStream outputStream = new FileOutputStream(firstPartName,true);
for(String state : name) {
FileInputStream inputStream = new FileInputStream(state);
// System.out.println(state);
byte[] buffer = new byte[inputStream.available()];
// int count = inputStream.read(buffer);
inputStream.read(buffer);
outputStream.write(buffer);
inputStream.close();
}
outputStream.close();
}
}