public class Solution {
    public static void main(String[] args) throws IOException {

        Map<String, ByteArrayOutputStream> map=new HashMap<>();
        ZipEntry ze;
        try (ZipInputStream zIn=new ZipInputStream(new FileInputStream(args[1]))) {
            while ((ze = zIn.getNextEntry()) != null) {
                ByteArrayOutputStream by = new ByteArrayOutputStream();
                int buffSize=1024;
                byte [] buff=new byte[buffSize];
                int readBytes;
                while ((readBytes=zIn.read(buff, 0 , buffSize)) >-1) {
                    by.write(buff, 0, readBytes);
                }
                map.put(ze.toString(), by);
                zIn.closeEntry();
            }
        }
        String fileName = args[0].substring(args[0].lastIndexOf('/')+1);
        ZipEntry newZe=new ZipEntry("new/" + fileName);
        try (ZipOutputStream zOut= new ZipOutputStream(new FileOutputStream(args[1]))) {
            zOut.putNextEntry(newZe);
            Files.copy(Paths.get(args[0]), zOut);
            zOut.closeEntry();
            for (Map.Entry<String, ByteArrayOutputStream> pair: map.entrySet()) {
                newZe = new ZipEntry(pair.getKey());
                if(!newZe.toString().endsWith(args[0])) {
                    zOut.putNextEntry(newZe);
                    zOut.write(pair.getValue().toByteArray());
                    zOut.closeEntry();
                }
            }
        }
    }
}