iWhiver
8/23/2019 - 5:54 AM

Copy, delete, remove files from archive withount unpacking

Map<String, String> zip_properties = new HashMap<>();
/* We want to read an existing ZIP File, so we set this to False */
zip_properties.put("create", "false");

/* Specify the path to the ZIP File that you want to read as a File System */
URI zip_disk = URI.create("jar:file:/D:/kms-trunk/KMS-Installer/build/distributions/KMS-Installer-6.0.jar");

/* Create ZIP file System */
try (FileSystem zipfs = FileSystems.newFileSystem(zip_disk, zip_properties)) {
    /* Get the Path inside ZIP File to copy the ZIP Entry */
    Path pathInZipfile = zipfs.getPath("server.kms.xml");
    System.out.println("About to copy an entry from ZIP File" + pathInZipfile.toUri());
    /* Execute Delete */
    Files.copy(pathInZipfile, Paths.get("C:\\Users\\IvanBelorechev\\Downloads\\server.kms.xml.my"));
    System.out.println("File successfully copied");
}