Не могу понять, что же здесь все-таки неверно. Выполнил все правильно, лишь не использовал Vector, как в решении от авторов.
package com.javarush.task.task31.task3106;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/*
Разархивируем файл
*/
public class Solution {
public static void main(String[] args) {
String resFile = args[0];
List<String> paths = new ArrayList<>();
for(int i = 1; i<args.length; i++) {
paths.add(args[i]);
}
Collections.sort(paths);
List<InputStream> inputStreams = paths.stream().map(x -> {
try {
return new FileInputStream(x);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
try(ZipInputStream zis = new ZipInputStream(new SequenceInputStream(Collections.enumeration(inputStreams)));
FileOutputStream fos = new FileOutputStream(resFile)) {
byte[] buffer = new byte[1024];
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
int c;
while((c = zis.read(buffer)) != -1) {
fos.write(c);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}