Добрый день, не прохожу по предпоследнему пункту. В чём же проблема?
package com.javarush.task.task31.task3105;
import java.io.*;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/*
Добавление файла в архив
*/
public class Solution {
public static void main(String[] args) throws IOException {
Map<String, byte[]> entries = new HashMap<>();
ZipInputStream in = new ZipInputStream(new FileInputStream(args[1]));
ZipEntry e;
while ((e = in.getNextEntry()) != null) {
int buff;
byte[] b = new byte[1024 * 1024];
while ((buff = in.read(b)) != -1) {
entries.put(e.getName(), b);
}
in.closeEntry();
}
in.close();
Path f = Paths.get(args[0]);
Files.copy(new FileInputStream(f.getFileName().toString()), f);
ZipEntry add = new ZipEntry("new/" + f.getFileName());
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(args[1]));
out.putNextEntry(add);
Files.copy(f, out);
out.closeEntry();
for (Map.Entry<String, byte[]> pair: entries.entrySet()) {
if (entries.containsKey(add.getName())) {
continue;
} else {
out.putNextEntry(new ZipEntry(pair.getKey()));
out.write(pair.getValue());
out.closeEntry();
}
}
out.close();
}
}