我想在 zip“archive.zip”中的“imp”目录中编辑文件“application.properties”。我为此使用 Truezip。我尝试同时使用 TFileOutputStream 和 TFileWriter。但是他们俩都在创建一个tmp文件,而不是在 zip 中编辑实际文件。zip 中的实际文件仍然保持不变。以下是我的代码示例: 1. 使用 TFileOutputStream:
OutputStream out = new TFileOutputStream("C:\sample\archive.zip\imp\application.properties");
// Loading properties code here
properties.store(out, null);
out.close();
- 使用 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(); }
请帮忙。