Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding file into existing Zip Archive
    primarykey
    data
    text
    <p>So I followed the block of code here: <a href="http://commons.apache.org/proper/commons-compress/examples.html" rel="nofollow">http://commons.apache.org/proper/commons-compress/examples.html</a>, where is said to simply make a ZipArchiveEntry and then insert the data. As you can see by my code below.</p> <pre><code> public void insertFile(File apkFile, File insert, String method) throws AndrolibException { ZipArchiveOutputStream out = null; ZipArchiveEntry entry; try { byte[] data = Files.toByteArray(insert); out = new ZipArchiveOutputStream(new FileOutputStream(apkFile, true)); out.setMethod(Integer.parseInt(method)); CRC32 crc = new CRC32(); crc.update(data); entry = new ZipArchiveEntry(insert.getName()); entry.setSize(data.length); entry.setTime(insert.lastModified()); entry.setCrc(crc.getValue()); out.putArchiveEntry(entry); out.write(data); out.closeArchiveEntry(); out.close(); } catch (FileNotFoundException ex) { throw new AndrolibException(ex); } catch (IOException ex) { throw new AndrolibException(ex); } } </code></pre> <p>Basically, its passed the File (apkFile) that will take the "insert" File, with another parameter dictating the compression method of that file. Running this block of code results in 0 errors, but the ZIP file only has that "new" file in it. It removes all the previous files and then inserts that new one.</p> <p>Prior to commons-compresss, I had to copy the entire Zip to a temporary file, do my changes, and then copy that finalized Zip file back. I thought this library worked around that though?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload