2 Replies Latest reply on Jan 18, 2011 10:16 PM by 832211

    Troubles copying binary file from zip file inside jar file

      I have a jar file with an embedded zip file. The zip file contains a directory structure with .png and .jpg files in it. I am attempting to copy the directory structure with the .png and .jpg files to a directory designated by the user. The directory structure is created and the .png and .jpg files are created, but I cannot read them, like it's attempting to do a text copy instead of a binary copy. The file sizes of the copied files seem to be a bit smaller than the originals, so it
      smells like the copy is ending too soon.

      The copy is not throwing an exception.

      Anyone have any hints or suggestions?


      Here is the code I am using:
                  InputStream is  = getClass().getResourceAsStream("resources/palettes_and_textures.zip");
                  ZipInputStream zipIn = new ZipInputStream(is);
                  ZipEntry entry = zipIn.getNextEntry();
                  while (entry != null)
                      if (entry.isDirectory())
                          File newDir  = new File(workDir + File.separator + entry.getName());
                          String sourcePath = entry.getName();
                          sourcePath = sourcePath.replace("/", File.separator);
                          FileOutputStream os = new FileOutputStream(workDir + File.separator + sourcePath);
                          BufferedReader br = new BufferedReader(new InputStreamReader(zipIn));
                          int dataByte = br.read();
                          while (dataByte != -1)
                              dataByte = br.read();
                      entry = zipIn.getNextEntry();
              catch(Exception e)
                  theDialog.updateStatus("Could not copy palettes or textures.  Permissions?", true);