0

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.

User1230321
  • 1,435
  • 4
  • 23
  • 39

1 Answers1

1

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

Christian Schlichtherle
  • 3,125
  • 1
  • 23
  • 47
  • This worked. But inside the zip, the things that got edited are going as a separate folder. Instead, apart from the file getting edited I don't want another folder to be created. Right now my zip has two folders instead of one. Please help – User1230321 Jul 31 '19 at 12:34
  • 1
    Check the `TConfig` class. You need to clear the `FsOutputOption.CREATE_PARENTS`. – Christian Schlichtherle Jul 31 '19 at 12:49