Hi, as in Title.
package pl.codegym.task.task18.task1825;
import java.io.*;
import java.util.*;
/*
Tworzenie pliku
*/
public class Solution {
public static void main(String[] args) throws IOException {
TreeMap<Integer, File> treeMap = new TreeMap<>();
String[ ] tab;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
tab = file1.split("\\.part");
treeMap.put(Integer.parseInt(tab[1]),new File(file1));
FileOutputStream fileOutputStream = new FileOutputStream(tab[0],true);
while(true) {
file1 = reader.readLine();
if(file1.equals("end")){
break;}
else{
tab = file1.split("\\.part");
treeMap.put(Integer.parseInt(tab[1]),new File(file1));
}
}
reader.close();
for (Map.Entry<Integer, File> para : treeMap.entrySet())
{
FileInputStream fileInputStream = new FileInputStream(para.getValue());
byte[] bytes = new byte[fileInputStream.available()];
while (fileInputStream.available() > 0) {
int count = fileInputStream.read(bytes);
fileOutputStream.write(bytes,0,count);
}
fileInputStream.close();
}
fileOutputStream.close();
}
}