private boolean createJar(String fileName) {
    /*
     * Make or modify the manifest (as appropriate), put the dex
     * array into the resources map, and then process the entire
     * resources map in a uniform manner.
     */

    try {
      Manifest manifest = makeManifest();
      OutputStream out = openOutput(fileName);
      JarOutputStream jarOut = new JarOutputStream(out, manifest);

      try {
        for (Map.Entry<String, byte[]> e : outputResources.entrySet()) {
          String name = e.getKey();
          byte[] contents = e.getValue();
          JarEntry entry = new JarEntry(name);
          int length = contents.length;

          if (args.verbose) {
            context.out.println("writing " + name + "; size " + length + "...");
          }

          entry.setSize(length);
          jarOut.putNextEntry(entry);
          jarOut.write(contents);
          jarOut.closeEntry();
        }
      } finally {
        jarOut.finish();
        jarOut.flush();
        closeOutput(out);
      }
    } catch (Exception ex) {
      if (args.debug) {
        context.err.println("\ntrouble writing output:");
        ex.printStackTrace(context.err);
      } else {
        context.err.println("\ntrouble writing output: " + ex.getMessage());
      }
      return false;
    }

    return true;
  }
Creates a jar file from the resources (including dex file arrays).

@param fileName {@code non-null;} name of the file
@return whether the creation was successful
android/android_framework/dex-maker/src/main/java/com/android/dx/command/dexer/Main.java