Reputation: 1105
Suppose I have a zipfile called mine.zip
. It contains the text files a.txt, b.txt, c.txt
.
I want to delete a.txt
from this zipfile without unzipping it.
Also can I copy this b.txt
from mine.zip
to any other place without unzipping it?
Finally can I copy d.txt
from sdcard to mine.zip
programatically?
Can this be done android. I have done all the above it with unzipping mine.zip
then rezipping it.
but can it be done without unzipping?
Upvotes: 0
Views: 551
Reputation: 31
U can try to find out ur target file from the zip file though ZipEntry. Then
FileInputStream fin = new FileInputStream(zipfile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry entry = null;
while ((entry = zin.getNextEntry()) != null) {
if (entry.getName().equals("aaa.txt")) {
if (entry.getSize() != 0) {
BufferedReader br = new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry)));
String line;
while ((line = br.readLine()) != null) {
sBuffer.append(line + "\r\n");
}
sbf.append(sBuffer);
br.close();
}
}
Upvotes: 1