Add new comment

Classloader and resources

Hello I am having problems extracting a zip file out of a jar I have as a resource.  I can extract it but the names of the files and directories are obfuscated.  On this page you mention "program or a third-party library uses ClassLoader explicitly, you may need to make a little change to your code, to use another ClassLoader, in order to be compatible with encryption.", can you explain how to do this?  I am attempting to extract the jar like this currently:

   File dstFile = new File(outputPath, newFileName);
   InputStream resource = Myclass.class.getResourceAsStream("/MyJarToExtract.jar");
   FileOutputStream outStream = new FileOutputStream(dstFile);

   byte[] buffer = new byte[1024];
   int bytes;
   while ((bytes = resource.read(buffer)) != -1) {
    outStream.write(buffer, 0, bytes);
   }
   outStream.close();
   resource.close();
   dstFilePath = dstFile.getAbsolutePath();
   return dstFile;