В файл складывается как надо, но валидацию не проходит ни один пункт кроме последнего. Не пойму куда копать(
package com.javarush.task.task18.task1825;
import java.util.*;
import java.io.*;
import java.text.*;
/*
Собираем файл
*/
public class Solution {
public static void main(String[] args) throws IOException, FileNotFoundException{
BufferedReader red = new BufferedReader(new InputStreamReader(System.in));
Map<String,byte[]> mapa = new HashMap<>();
String fileName = "";
String filePath = "";
while (true){
fileName = red.readLine();
if(fileName.equals("end")){
break;
}
filePath = "c:\\" + fileName;
FileInputStream fis = new FileInputStream(filePath);
byte[]buffer=new byte[fis.available()];
while(fis.available()>0){
fis.read(buffer);
}
mapa.put(filePath,buffer);
fis.close();
}
red.close();
for(int i = filePath.length(); i > 0; i--){
if(filePath.substring(i-1,i).equals(".")){
filePath = filePath.substring(0,i-1);
break;
}
}
FileOutputStream fos = new FileOutputStream(filePath,true);
TreeMap <String,byte[]> sorted = new TreeMap<>();
sorted.putAll(mapa);
for(Map.Entry<String,byte[]> pair: sorted.entrySet()){
fos.write(pair.getValue());
}
fos.close();
}
}