Hi Guys,
I am trying to read content of a zip file(that is on sd card). I want
to read xml file from that zip file.
Here is my code:

public String getGameMetaData(String pathToFile) throws IOException {
               zipFile = new ZipFile(pathToFile);
               packageData = new StringBuilder();

               Enumeration<?> zipEntries = zipFile.entries();

               while (zipEntries.hasMoreElements()) {
                       // zipEntries.nextElement()).getName());

                       zipEntry = (ZipEntry) zipEntries.nextElement();

                       if (!zipEntry.isDirectory()) {
                               if(zipEntry.getName().equals
("metadata.xml")) {
                                       bis = new BufferedInputStream
(zipFile
                                                       .getInputStream
(zipEntry));
                                       dis = new DataInputStream(bis);
                                       while (dis.available() != 0) {
                                               packageData.append
(dis.readLine());
                                       }
                               }
                       }

               }
               Log.i("Data", packageData.toString());
               return packageData.toString();
       }
Now, this code is running fine if I call it from my sample application
activity. It's returning xml file content.
But when I call this same method from my service (that is actually i
want), it throws an error: java.util.zipException: too short to be
zip.

>From activity class(of my sample application) it's working and from
service, it's not working.  it shows this exception on line - "zipFile
= new ZipFile(pathToFile);" - 1st line of the method.

Plzz help me to solve this issue.

Thanks
Harshit
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to