глянет кто код )
package com.javarush.task.task18.task1825;
import java.io.*;
import java.util.*;
/*
Собираем файл
*/
public class Solution {
public static void main(String[] args) throws Exception{
ArrayList<String> list = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(true){
String faleName = reader.readLine();
if(faleName.equals("end"))
break;
list.add(faleName);}
reader.close();
Collections.sort(list);
String file = list.get(0);
int index = file.lastIndexOf('.');
file = file.substring(0,index+1);
FileOutputStream otf = new FileOutputStream(file);
for(int i = 0; i<list.size(); i++){
FileInputStream fIn = new FileInputStream(list.get(i));
byte[] byff = new byte[fIn.available()];
while(fIn.available() > 0){
int count = fIn.read(byff);
otf.write(byff, 0, count);}
fIn.close();
}
otf.close();
}
}