Java Code Examples for java.util.Enumeration#hasMoreElements()

The following examples show how to use java.util.Enumeration#hasMoreElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolidityResult.java    From securify with Apache License 2.0 6 votes vote down vote up
/**
 * Get the Securify version from the MANIFEST
 *
 * @return The version of Securify being executed
 */
private static String getVersion() {
    String className = Main.class.getCanonicalName();
    try {
        Enumeration<URL> resources = Main.class.getClassLoader()
                .getResources("META-INF/MANIFEST.MF");
        while (resources.hasMoreElements()) {
            Manifest manifest = new Manifest(resources.nextElement().openStream());
            Attributes at = manifest.getMainAttributes();
            Object main = at.getValue(MAIN_CLASS);
            if (main != null && at.getValue(MAIN_CLASS).equals(className) ) {
                return at.getValue(IMPLEMENTATION_VERSION);
            }
        }
    } catch (IOException e) {
        System.err.println("Error while setting Securify version");
        e.printStackTrace();
    }
    return "unknown_version";
}
 
Example 2
Source File: SwaggerUiProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void extractSwaggerUi(AppArtifact artifact, Path resourceDir) throws IOException {
    final String versionedSwaggerUiWebjarPrefix = format("%s/%s/", SWAGGER_UI_WEBJAR_PREFIX, artifact.getVersion());
    for (Path p : artifact.getPaths()) {
        File artifactFile = p.toFile();
        try (JarFile jarFile = new JarFile(artifactFile)) {
            Enumeration<JarEntry> entries = jarFile.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = entries.nextElement();
                if (entry.getName().startsWith(versionedSwaggerUiWebjarPrefix) && !entry.isDirectory()) {
                    try (InputStream inputStream = jarFile.getInputStream(entry)) {
                        String filename = entry.getName().replace(versionedSwaggerUiWebjarPrefix, "");
                        Files.copy(inputStream, resourceDir.resolve(filename));
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: OzoneConfiguration.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
private void loadDefaults() {
  try {
    //there could be multiple ozone-default-generated.xml files on the
    // classpath, which are generated by the annotation processor.
    // Here we add all of them to the list of the available configuration.
    Enumeration<URL> generatedDefaults =
        OzoneConfiguration.class.getClassLoader().getResources(
            "ozone-default-generated.xml");
    while (generatedDefaults.hasMoreElements()) {
      addResource(generatedDefaults.nextElement());
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  // Adding core-site here because properties from core-site are
  // distributed to executors by spark driver. Ozone properties which are
  // added to core-site, will be overriden by properties from adding Resource
  // ozone-default.xml. So, adding core-site again will help to resolve
  // this override issue.
  addResource("core-site.xml");
  addResource("ozone-site.xml");
}
 
Example 4
Source File: MultiUIDefaults.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized String toString() {
    StringBuffer buf = new StringBuffer();
    buf.append("{");
    Enumeration keys = keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        buf.append(key + "=" + get(key) + ", ");
    }
    int length = buf.length();
    if (length > 1) {
        buf.delete(length-2, length);
    }
    buf.append("}");
    return buf.toString();
}
 
Example 5
Source File: NotificationMgtConfigBuilder.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Build a list of subscription by a particular module
 *
 * @param moduleName       Name of the module
 * @param moduleProperties Set of properties which
 * @return A list of subscriptions by the module
 */
private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) {
    // Get subscribed events
    Properties subscriptions = NotificationManagementUtils.getSubProperties(moduleName + "." +
            NotificationMgtConstants.Configs.SUBSCRIPTION, moduleProperties);

    List<Subscription> subscriptionList = new ArrayList<Subscription>();
    Enumeration propertyNames = subscriptions.propertyNames();
    // Iterate through events and build event objects
    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        String subscriptionName = (String) subscriptions.remove(key);
        // Read all the event properties starting from the event prefix
        Properties subscriptionProperties = NotificationManagementUtils.getPropertiesWithPrefix
                (moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION + "." + subscriptionName,
                        moduleProperties);
        Subscription subscription = new Subscription(subscriptionName, subscriptionProperties);
        subscriptionList.add(subscription);
    }
    return subscriptionList;
}
 
Example 6
Source File: DjVuText.java    From djvu-html5 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches a file for TXTz and TXTa chunks and decodes each of them.
 *
 * @param iff enumeration of CachedInputStream's to read.
 *
 * @return the initialized DjVuText object
 *
 * @throws IOException if an IO error occures.
 */
public DjVuText init(final Enumeration<CachedInputStream> iff)
  throws IOException
{
  if(iff != null)
  {
    while(iff.hasMoreElements())
    {
      CachedInputStream chunk=iff.nextElement();
      final String xchkid = chunk.getName();
      if(xchkid.startsWith("FORM:"))
      {
        init(chunk.getIFFChunks());
      }
      else if("TXTa".equals(xchkid)||"TXTz".equals(xchkid))
      {
        decode(chunk);
      }
    }
  }
  return this;
}
 
Example 7
Source File: BasicPermission.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * readObject is called to restore the state of the
 * BasicPermissionCollection from a stream.
 */
private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException
{
    // Don't call defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();

    // Get permissions
    // writeObject writes a Hashtable<String, Permission> for the
    // permissions key, so this cast is safe, unless the data is corrupt.
    @SuppressWarnings("unchecked")
    Hashtable<String, Permission> permissions =
            (Hashtable<String, Permission>)gfields.get("permissions", null);
    perms = new HashMap<String, Permission>(permissions.size()*2);
    perms.putAll(permissions);

    // Get all_allowed
    all_allowed = gfields.get("all_allowed", false);

    // Get permClass
    permClass = (Class<?>) gfields.get("permClass", null);

    if (permClass == null) {
        // set permClass
        Enumeration<Permission> e = permissions.elements();
        if (e.hasMoreElements()) {
            Permission p = e.nextElement();
            permClass = p.getClass();
        }
    }
}
 
Example 8
Source File: AlternativeDriver.java    From tomee with Apache License 2.0 5 votes vote down vote up
private boolean isRegistered() {
    final Enumeration<Driver> drivers = DriverManager.getDrivers();
    while (drivers.hasMoreElements()) {

        final Driver driver = drivers.nextElement();

        if (driver == this) {
            return true;
        }
    }

    return false;
}
 
Example 9
Source File: TestConfiguration.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create a copy of this configuration with some additional connection
 * attributes.
 *
 * @param attrs the extra connection attributes
 * @return a copy of the configuration with extra attributes
 */
TestConfiguration addConnectionAttributes(Properties attrs) {
    TestConfiguration copy = new TestConfiguration(this);
    Enumeration e = attrs.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String val = attrs.getProperty(key);
        copy.connectionAttributes.setProperty(key, val);
    }
    copy.initConnector(connector);
    return copy;
}
 
Example 10
Source File: OASISCatalogManager.java    From cxf with Apache License 2.0 5 votes vote down vote up
public final void loadCatalogs(ClassLoader classLoader, String name) throws IOException {
    if (classLoader == null) {
        return;
    }

    Enumeration<URL> catalogs = classLoader.getResources(name);
    while (catalogs.hasMoreElements()) {
        final URL catalogURL = catalogs.nextElement();
        if (catalog == null) {
            LOG.log(Level.WARNING, "Catalog found at {0} but no org.apache.xml.resolver.CatalogManager was found."
                    + "  Check the classpatch for an xmlresolver jar.", catalogURL.toString());
        } else if (!loadedCatalogs.contains(catalogURL.toString())) {
            final SecurityManager sm = System.getSecurityManager();
            if (sm == null) {
                ((Catalog)catalog).parseCatalog(catalogURL);
            } else {
                try {
                    AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                        @Override
                        public Void run() throws Exception {
                            ((Catalog)catalog).parseCatalog(catalogURL);
                            return null;
                        }
                    });
                } catch (PrivilegedActionException e) {
                    throw (IOException) e.getException();
                }
            }
            loadedCatalogs.add(catalogURL.toString());
        }
    }
}
 
Example 11
Source File: SendMailService.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
private void addEncryptionSettings() throws Exception {
    URL keystoreUrl = new URL(input.getEncryptionKeystore());
    try (InputStream publicKeystoreInputStream = keystoreUrl.openStream()) {
        char[] smimePw = input.getEncryptionKeystorePassword().toCharArray();
        gen = new SMIMEEnvelopedGenerator();
        Security.addProvider(new BouncyCastleProvider());
        KeyStore ks = KeyStore.getInstance(SecurityConstants.PKCS_KEYSTORE_TYPE, SecurityConstants.BOUNCY_CASTLE_PROVIDER);
        ks.load(publicKeystoreInputStream, smimePw);

        if (StringUtils.EMPTY.equals(input.getEncryptionKeyAlias())) {
            Enumeration aliases = ks.aliases();
            while (aliases.hasMoreElements()) {
                String alias = (String) aliases.nextElement();

                if (ks.isKeyEntry(alias)) {
                    input.setEncryptionKeyAlias(alias);
                }
            }
        }

        if (StringUtils.EMPTY.equals(input.getEncryptionKeyAlias())) {
            throw new Exception(ExceptionMsgs.PUBLIC_KEY_ERROR_MESSAGE);
        }

        Certificate[] chain = ks.getCertificateChain(input.getEncryptionKeyAlias());

        if (chain == null) {
            throw new Exception("The key with alias \"" + input.getEncryptionKeyAlias() + "\" can't be found in given keystore.");
        }

        //
        // create the generator for creating an smime/encrypted message
        //
        gen.addKeyTransRecipient((X509Certificate) chain[0]);
    }
}
 
Example 12
Source File: ObfuscatorTest.java    From obfuscator with MIT License 5 votes vote down vote up
@Test
public void testObfuscatedJar() throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    int rightValue = 704643072;
    JarFile jarFile = new JarFile(obfuscatedFile);
    Enumeration<JarEntry> e = jarFile.entries();

    URL[] urls = {new URL("jar:file:" + obfuscatedFile.getAbsolutePath() + "!/")};
    URLClassLoader cl = URLClassLoader.newInstance(urls);
    Class<?> c = null;

    while (e.hasMoreElements()) {
        JarEntry je = e.nextElement();
        if (je.isDirectory() || !je.getName().endsWith(".class")) {
            continue;
        }
        // -6 because of .class
        String className = je.getName().substring(0, je.getName().length() - 6);
        className = className.replace('/', '.');
        if (className.equals("JFT")) {
            c = cl.loadClass(className);
        }
    }

    if (c == null) {
        fail("JFT.class wasn't found");
    }

    assertEquals(((int) c.getMethod("test").invoke(null)), rightValue);
}
 
Example 13
Source File: V2TBSCertListGenerator.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public TBSCertList generateTBSCertList()
{
    if ((signature == null) || (issuer == null) || (thisUpdate == null))
    {
        throw new IllegalStateException("Not all mandatory fields set in V2 TBSCertList generator.");
    }

    ASN1EncodableVector  v = new ASN1EncodableVector();

    v.add(version);
    v.add(signature);
    v.add(issuer);

    v.add(thisUpdate);
    if (nextUpdate != null)
    {
        v.add(nextUpdate);
    }

    // Add CRLEntries if they exist
    if (crlentries != null)
    {
        ASN1EncodableVector certs = new ASN1EncodableVector();
        Enumeration it = crlentries.elements();
        while(it.hasMoreElements())
        {
            certs.add((ASN1Sequence)it.nextElement());
        }
        v.add(new DERSequence(certs));
    }

    if (extensions != null)
    {
        v.add(new DERTaggedObject(0, extensions));
    }

    return new TBSCertList(new DERSequence(v));
}
 
Example 14
Source File: NewPluginPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public List<String> getGoals () {
    List<String> goals = new ArrayList<String>();
    Enumeration e  = listModel.elements();
    GoalEntry ge;
    while (e.hasMoreElements()) {
        ge = (GoalEntry) e.nextElement();
        if (ge.isSelected) {
            goals.add(ge.name);
        }
    }
    return goals;
}
 
Example 15
Source File: MockAttributeSet.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void addAttributes(AttributeSet attr)
{
    Enumeration<?> as = attr.getAttributeNames();
    while(as.hasMoreElements()) {
        Object el = as.nextElement();
        backing.put(el, attr.getAttribute(el));
    }
}
 
Example 16
Source File: Mod.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Lengthen each note in the CPhrase.
    *
    * <P> See {@link #elongate(Phrase, double)} for further details.
    *
    * <P> If <CODE>cphrase</CODE> is null or <CODE>scaleFactor</CODE> is less
    * than or equal to zero then this method does nothing.
    *
    * @param cphrase       CPhrase to be lengthened
    * @param scaleFactor   double describing the scale factor
 */
   public static void elongate(CPhrase cphrase, final double scaleFactor) {
       if (cphrase == null || scaleFactor <= 0.0) {
           return;
       }
       Enumeration enum1 = cphrase.getPhraseList().elements();
	while(enum1.hasMoreElements()){
		Phrase phr = ((Phrase) enum1.nextElement());
           elongate(phr, scaleFactor);
		phr.setStartTime(phr.getStartTime() * scaleFactor);
	}
}
 
Example 17
Source File: JmsFactory.java    From nifi with Apache License 2.0 4 votes vote down vote up
public static Map<String, String> createAttributeMap(final Message message) throws JMSException {
    final Map<String, String> attributes = new HashMap<>();

    final Enumeration<?> enumeration = message.getPropertyNames();
    while (enumeration.hasMoreElements()) {
        final String propName = (String) enumeration.nextElement();

        final Object value = message.getObjectProperty(propName);

        if (value == null) {
            attributes.put(ATTRIBUTE_PREFIX + propName, "");
            attributes.put(ATTRIBUTE_PREFIX + propName + ATTRIBUTE_TYPE_SUFFIX, "Unknown");
            continue;
        }

        final String valueString = value.toString();
        attributes.put(ATTRIBUTE_PREFIX + propName, valueString);

        final String propType;
        if (value instanceof String) {
            propType = PROP_TYPE_STRING;
        } else if (value instanceof Double) {
            propType = PROP_TYPE_DOUBLE;
        } else if (value instanceof Float) {
            propType = PROP_TYPE_FLOAT;
        } else if (value instanceof Long) {
            propType = PROP_TYPE_LONG;
        } else if (value instanceof Integer) {
            propType = PROP_TYPE_INTEGER;
        } else if (value instanceof Short) {
            propType = PROP_TYPE_SHORT;
        } else if (value instanceof Byte) {
            propType = PROP_TYPE_BYTE;
        } else if (value instanceof Boolean) {
            propType = PROP_TYPE_BOOLEAN;
        } else {
            propType = PROP_TYPE_OBJECT;
        }

        attributes.put(ATTRIBUTE_PREFIX + propName + ATTRIBUTE_TYPE_SUFFIX, propType);
    }

    if (message.getJMSCorrelationID() != null) {
        attributes.put(ATTRIBUTE_PREFIX + JMS_CORRELATION_ID, message.getJMSCorrelationID());
    }
    if (message.getJMSDestination() != null) {
        String destinationName;
        if (message.getJMSDestination() instanceof Queue) {
            destinationName = ((Queue) message.getJMSDestination()).getQueueName();
        } else {
            destinationName = ((Topic) message.getJMSDestination()).getTopicName();
        }
        attributes.put(ATTRIBUTE_PREFIX + JMS_DESTINATION, destinationName);
    }
    if (message.getJMSMessageID() != null) {
        attributes.put(ATTRIBUTE_PREFIX + JMS_MESSAGE_ID, message.getJMSMessageID());
    }
    if (message.getJMSReplyTo() != null) {
        attributes.put(ATTRIBUTE_PREFIX + JMS_REPLY_TO, message.getJMSReplyTo().toString());
    }
    if (message.getJMSType() != null) {
        attributes.put(ATTRIBUTE_PREFIX + JMS_TYPE, message.getJMSType());
    }

    attributes.put(ATTRIBUTE_PREFIX + JMS_DELIVERY_MODE, String.valueOf(message.getJMSDeliveryMode()));
    attributes.put(ATTRIBUTE_PREFIX + JMS_EXPIRATION, String.valueOf(message.getJMSExpiration()));
    attributes.put(ATTRIBUTE_PREFIX + JMS_PRIORITY, String.valueOf(message.getJMSPriority()));
    attributes.put(ATTRIBUTE_PREFIX + JMS_REDELIVERED, String.valueOf(message.getJMSRedelivered()));
    attributes.put(ATTRIBUTE_PREFIX + JMS_TIMESTAMP, String.valueOf(message.getJMSTimestamp()));
    return attributes;
}
 
Example 18
Source File: MCREchoResource.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@MCRRestrictedAccess(MCRRequireLogin.class)
public String doEcho() {
    Gson gson = new Gson();
    JsonObject jRequest = new JsonObject();
    jRequest.addProperty("secure", request.isSecure());
    jRequest.addProperty("authType", request.getAuthType());
    jRequest.addProperty("context", request.getContextPath());
    jRequest.addProperty("localAddr", request.getLocalAddr());
    jRequest.addProperty("localName", request.getLocalName());
    jRequest.addProperty("method", request.getMethod());
    jRequest.addProperty("pathInfo", request.getPathInfo());
    jRequest.addProperty("protocol", request.getProtocol());
    jRequest.addProperty("queryString", request.getQueryString());
    jRequest.addProperty("remoteAddr", request.getRemoteAddr());
    jRequest.addProperty("remoteHost", request.getRemoteHost());
    jRequest.addProperty("remoteUser", request.getRemoteUser());
    jRequest.addProperty("remotePort", request.getRemotePort());
    jRequest.addProperty("requestURI", request.getRequestURI());
    jRequest.addProperty("scheme", request.getScheme());
    jRequest.addProperty("serverName", request.getServerName());
    jRequest.addProperty("servletPath", request.getServletPath());
    jRequest.addProperty("serverPort", request.getServerPort());

    HttpSession session = request.getSession(false);
    List<String> attributes = Collections.list(session.getAttributeNames());
    JsonObject sessionJSON = new JsonObject();
    JsonObject attributesJSON = new JsonObject();
    attributes.forEach(attr -> attributesJSON.addProperty(attr, session.getAttribute(attr).toString()));
    sessionJSON.add("attributes", attributesJSON);
    sessionJSON.addProperty("id", session.getId());
    sessionJSON.addProperty("creationTime", session.getCreationTime());
    sessionJSON.addProperty("lastAccessedTime", session.getLastAccessedTime());
    sessionJSON.addProperty("maxInactiveInterval", session.getMaxInactiveInterval());
    sessionJSON.addProperty("isNew", session.isNew());
    jRequest.add("session", sessionJSON);

    jRequest.addProperty("localPort", request.getLocalPort());
    JsonArray jLocales = new JsonArray();
    Enumeration<Locale> locales = request.getLocales();
    while (locales.hasMoreElements()) {
        jLocales.add(gson.toJsonTree(locales.nextElement().toString()));
    }
    jRequest.add("locales", jLocales);
    JsonObject header = new JsonObject();
    jRequest.add("header", header);
    Enumeration<String> headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        String headerValue = request.getHeader(headerName);
        header.addProperty(headerName, headerValue);
    }
    JsonObject parameter = new JsonObject();
    jRequest.add("parameter", parameter);
    for (Map.Entry<String, String[]> param : request.getParameterMap().entrySet()) {
        if (param.getValue().length == 1) {
            parameter.add(param.getKey(), gson.toJsonTree(param.getValue()[0]));
        } else {
            parameter.add(param.getKey(), gson.toJsonTree(param.getValue()));
        }
    }
    return jRequest.toString();
}
 
Example 19
Source File: InstallHookProcessorImpl.java    From jackrabbit-filevault with Apache License 2.0 4 votes vote down vote up
public void registerHooks(Archive archive, ClassLoader classLoader) throws PackageException {
    try {
        Archive.Entry root = archive.getRoot();
        root = root.getChild(Constants.META_INF);
        if (root == null) {
            log.warn("Archive {} does not have a {} directory.", archive, Constants.META_INF);
            return;
        }
        root = root.getChild(Constants.VAULT_DIR);
        if (root == null) {
            log.warn("Archive {} does not have a {} directory.", archive, Constants.VAULT_DIR);
            return;
        }
        root = root.getChild(Constants.HOOKS_DIR);
        if (root == null) {
            log.debug("Archive {} does not have a {} directory.", archive, Constants.HOOKS_DIR);
        } else {
            for (Archive.Entry entry : root.getChildren()) {
                // only respect .jar files
                if (entry.getName().endsWith(".jar")) {
                    registerHook(archive.getInputSource(entry), classLoader);
                }
            }
        }
        
        // also look for external hooks in properties
        // currently only the format: "installhook.{name}.class" is supported
        Properties props = archive.getMetaInf().getProperties();
        if (props != null) {
            Enumeration<?> names = props.propertyNames();
            while (names.hasMoreElements()) {
                String name = names.nextElement().toString();
                if (name.startsWith(VaultPackage.PREFIX_INSTALL_HOOK)) {
                    String[] segs = Text.explode(name.substring(VaultPackage.PREFIX_INSTALL_HOOK.length()), '.');
                    if (segs.length == 0 || segs.length > 2 || !"class".equals(segs[1])) {
                        throw new PackageException("Invalid installhook property: " + name);
                    }
                    Hook hook = new Hook(segs[0], props.getProperty(name), classLoader);
                    initHook(hook);
                }
            }
        }
    } catch (IOException e) {
        throw new PackageException("I/O Error while registering hooks", e);
    }
}
 
Example 20
Source File: RouterInitGenerator.java    From MRouter with Apache License 2.0 4 votes vote down vote up
public static void updateInitClassBytecode(GlobalInfo globalInfo) throws IOException {
    for (File file : globalInfo.getRouterInitTransformFiles()) {
        if (file.getName().endsWith(".jar")) {
            JarFile jarFile = new JarFile(file);
            Enumeration enumeration = jarFile.entries();

            // create tmp jar file
            File tmpJarFile = new File(file.getParent(), file.getName() + ".tmp");

            if (tmpJarFile.exists()) {
                tmpJarFile.delete();
            }

            JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(tmpJarFile));

            while (enumeration.hasMoreElements()) {
                JarEntry jarEntry = (JarEntry) enumeration.nextElement();
                // eg. com/google/common/collect/AbstractTable.class
                String entryName = jarEntry.getName();
                ZipEntry zipEntry = new ZipEntry(entryName);
                InputStream inputStream = jarFile.getInputStream(jarEntry);
                jarOutputStream.putNextEntry(zipEntry);
                if (Utils.isRouterInitClass(globalInfo, entryName.replace(".class", ""))) {
                    byte[] bytes = generateClassBytes(globalInfo, inputStream);
                    jarOutputStream.write(bytes);
                } else {
                    jarOutputStream.write(IOUtils.toByteArray(inputStream));
                }
                // inputStream.close(); close by ClassReader
                jarOutputStream.closeEntry();
            }
            jarOutputStream.close();
            jarFile.close();

            if (file.exists()) {
                file.delete();
            }
            tmpJarFile.renameTo(file);
        } else {
            byte[] classBytes = generateClassBytes(globalInfo, new FileInputStream(file));
            FileUtils.writeByteArrayToFile(file, classBytes, false);
        }
    }
}