Не проходит даже первый пункт. Что-то я перегрелся наверное уже.
package com.javarush.task.task18.task1825;
/*
Собираем файл
*/
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Map<Integer,String> map = new TreeMap<Integer,String>();
String fileOutputName = null;
while(true) {
String fileName = reader.readLine();
if(fileName.equals("end")) {
reader.close();
break;
}
String sub[] = fileName.split("\\.");
int part = Integer.parseInt(sub[2].substring(5));
if(fileOutputName==null) {
fileOutputName = sub[0] + "." + sub[1];}
map.put(part,fileName);
}
OutputStream fileOutput = new FileOutputStream(fileOutputName);
for(Map.Entry<Integer, String> file : map.entrySet()) {
InputStream fileinput = new FileInputStream(file.getValue());
byte buffer[] = new byte[fileinput.available()];
for(;fileinput.available()>0;) {
int c = fileinput.read(buffer);
}
for(int i=0;i<buffer.length;i++) {
fileOutput.write(buffer[i]);
}
fileinput.close();
}
fileOutput.close();
}
}