public String removeParcel(File document, String parcelName)
throws IOException {
ZipInputStream documentStream = null;
ZipOutputStream outStream = null;
Manifest manifest = null;
if (!parcelName.startsWith(PARCEL_PREFIX_DIR))
parcelName = PARCEL_PREFIX_DIR + parcelName;
manifest = removeParcelFromManifest(document, parcelName);
// first write contents of document to tmpfile
File tmpfile = new File(document.getAbsolutePath() + ".tmp");
try {
ZipEntry outEntry;
ZipEntry inEntry;
byte[] bytes = new byte[1024];
int len;
documentStream = new ZipInputStream(new FileInputStream(document));
outStream = new ZipOutputStream(new FileOutputStream(tmpfile));
while ((inEntry = documentStream.getNextEntry()) != null) {
if(inEntry.getName().startsWith(parcelName))
continue;
outEntry = new ZipEntry(inEntry);
outStream.putNextEntry(outEntry);
if(inEntry.getName().equals("META-INF/manifest.xml") &&
manifest != null) {
InputStream manifestStream = null;
try {
manifestStream = manifest.getInputStream();
while ((len = manifestStream.read(bytes)) != -1)
outStream.write(bytes, 0, len);
}
finally {
if (manifestStream != null)