I m creating a zip file with the following code
extract_temp is the folder, which has the data to be zipped to story.The extract_ temp has the following structure.
extract_temp
jpg
hello.jpg
hello1.jpg
.....
wav
hello.wav
hello1.wav
.....
story.xml
FileOutputStream FOS = new FileOutputStream(story);// story is the zip file to be created
ZipOutputStream ZOS = new ZipOutputStream(FOS);
String rootPath = "extract_temp";//the folder where i have data to be zipped
File root = new File(rootPath);
recursivelyGetAllFiles(root); //gets all the files in output vector
for(int i = 0;i<output.size(); i++)
{
File x = new File((String)output.elementAt(i));
if(x.isFile())
{
String path = x.getAbsolutePath();
int index = path.indexOf(rootPath);
index += rootPath.length() + 1;
if(index > path.length())
continue;
String name = path.substring(index);
ZipEntry entry = new ZipEntry(name);
ZOS.putNextEntry(entry);
myFileStreamReader = new FileInputStream(path);
sizeRead = 0;
totalSize = 0;
while ((sizeRead = myFileStreamReader.read(readBytes)) > 0)
{
ZOS.write(readBytes, 0, sizeRead);
totalSize += sizeRead;
}
myFileStreamReader = null;
ZOS.flush();
ZOS.closeEntry();
}
}
ZOS.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
The story that is created when extracted through my
java code, could not find the content such as story.xml.
However if extract_temp is manually zipped, the zipped file works absolutely fine.So i m sure that my extract zip code is working properly.
The problem i suspect, is somewhere..while making zip entry in teh above code.
help,
Thanks in anticipation,
Shelly.