Search code examples
editziptruezip

Editing file in zip using Truezip is creating a tmp file, but not editing the file inside zip


I want to edit a file "application.properties" inside "imp" directory inside a zip "archive.zip". I'm using Truezip for this. I tried using both TFileOutputStream and TFileWriter. But both of them are creating a tmp file, but not editing the actual file in zip. The actual file in zip still remains same. Below are my code samples: 1. Using TFileOutputStream:

    OutputStream out = new TFileOutputStream("C:\sample\archive.zip\imp\application.properties");
    // Loading properties code here
    properties.store(out, null);
    out.close();
  1. Using TFileWriter:
File entry = new TFile("C:\sample\archive.zip\imp\application.properties");
Writer writer = new TFileWriter(entry);
try {
    writer.write("wish.world=Hello world\n");
} finally {
    writer.close();
}

Kindly help.


Solution

  • You need to call TVFS.umount() to persist your changes.