code: public static boolean extract(File jarFile, File newJar, String[] includePrefixes, String[] excludePrefixes) throws IOException {
          boolean isSomethingExtracted = false;
          if (!jarFile.exists()) {
              Log.w("Jar file does not exists at: " + jarFile.getAbsolutePath());
              return isSomethingExtracted;
          }
  
          ZipInputStream zis = new ZipInputStream(new FileInputStream(jarFile));
          ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(newJar));
          for (ZipEntry entry = zis.getNextEntry(); entry != null; entry = zis.getNextEntry()) {
              String name = entry.getName().replaceAll("/", ".").replace(".class", "");
              boolean isStartsWith = startsWith(name, includePrefixes) && !startsWith(name, excludePrefixes);
              isSomethingExtracted = isSomethingExtracted || isStartsWith;
              if (isStartsWith || name.startsWith("META-INF")) {
                  zos.putNextEntry(new ZipEntry(entry.getName()));
                  int data;
                  while ((data = zis.read()) != -1) {
                      zos.write(data);
                  }
                  zos.closeEntry();
              }
          }
          zis.close();
          try {
              zos.close();
          } catch (ZipException e) {
              System.out.println("No classes in the original jar matched the prefix");
          }
          return isSomethingExtracted;
      }
docs: Creates a jar file that contains only classes with specified prefix. Note
  that new jar is created in the same directory as the original jar
  (hopefully the user has write permission).
  
  Returns true if classes with the given prefix are detected.
  
  @throws IOException
  if a file is not found or there is some error during
  read/write operations