I sick and tired from this one, I know that it is no good, but wanted to know what do you guys think about it, and what is wrong, I cant look at it anymore, and I have to move on to the next one, because i am stuck at this problem for far too long..
package com.codegym.task.task18.task1825;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Building a file
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName;
String outputFile = "";
Map<String, Integer> map = new TreeMap<>();
while(!(fileName = reader.readLine()).equals("end")){
String[]split = fileName.split(".");
if(split.length>2){
int partNum = Integer.parseInt(split[2].substring(4));
map.put(fileName, partNum);
}
else{
outputFile = fileName;
}
}
for(Map.Entry<String, Integer> entry : map.entrySet()){
String key = entry.getKey();
FileInputStream fis = new FileInputStream(key);
byte[]buffer = new byte[fis.available()];
fis.read(buffer);
FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(buffer);
fis.close();
fos.close();
}
}
}