Что может не нравится этому бармалею?
Все условия соблюдены, вывод правильный...
package com.javarush.task.task18.task1825;
/*
Собираем файл
*/
import java.io.*;
import java.util.TreeSet;
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
String fileName = "";
TreeSet<String> fileParts = new TreeSet<>();
String line;
while (!(line = console.readLine()).equals("end"))
{
fileName = line.substring(0, line.indexOf(".part"));
fileParts.add(line.substring(line.indexOf(".") + 1));
}
for (String filepart : fileParts)
{
appendFiles(fileName, filepart);
}
}
private static void appendFiles(String fileName, String filePart)
{
//System.out.println(fileName.concat(".").concat(filePart));
//System.out.println(fileName);
try (BufferedInputStream bfis = new BufferedInputStream(new FileInputStream(fileName.concat(".").concat(filePart))))
{
BufferedOutputStream bfos = new BufferedOutputStream(new FileOutputStream(fileName, true));
byte[] buffer = new byte[bfis.available()];
while (bfis.available() > 0)
{
bfis.read(buffer);
bfos.write(buffer);
//bfos.write(bfis.read());
//System.out.println(bfis.available());
}
bfos.close();
}
catch (FileNotFoundException e)
{
System.out.println("No such file");
}
catch (IOException e)
{
System.out.println("Error while reading");
}
}
}