Examples of JarEntry


Examples of java.util.jar.JarEntry

        if (jar == null)
            throw new ClassNotFoundException();

        try {
            // find the entry in the Jar file
            JarEntry entry = jar.getJarEntry(className);
            InputStream stream = jar.getInputStream(entry);

            // read it into a class
            int len = (int) entry.getSize();
            int offset = 0;
            int success = 0;
            byte[] contents = new byte[len];

            while (success < len) {
                len -= success;
                offset += success;
                success = stream.read(contents, offset, len);
                if (success == -1)
                    throw new ClassNotFoundException();
            }

            stream.read(contents, 0, (int) entry.getSize());

            // actually define the class
            result = defineClass(origName, contents, 0, contents.length);

            if (resolveIt)
View Full Code Here

Examples of java.util.jar.JarEntry

     * @param name
     *            the name of the file you want to get the entry for
     * @return The jarEntry value
     */
    public JarEntry getJarEntry(String name) {
        JarEntry entry = null;
        try {
            entry = jar.getJarEntry(name);
        } catch (IllegalStateException ex) {
            try {
                jar = new JarFile(location);
View Full Code Here

Examples of java.util.jar.JarEntry

     */
    public void loadContents() throws IOException {
        contents.removeAll(contents);
        Enumeration e = jar.entries();
        while (e.hasMoreElements()) {
            JarEntry entry = (JarEntry) e.nextElement();

            // if it contains the file "plugin.properties", it's a plugin
            // so read in the properties file
            if (entry.getName().equals("plugin.properties")) {
                InputStream stream = jar.getInputStream(entry);
                props.load(stream);

                File file = new File(location);

                props.setProperty("size", "" + file.length());
                props.setProperty("fileName", file.getPath());
                stream.close();
            }

            contents.add(entry.getName());
        }
    }
View Full Code Here

Examples of java.util.jar.JarEntry

    private InputStream getConnectorXmlInputStream(File file) {
        try {
            if (isJarFile(file)) {
                JarFile jar = new JarFile(file);
                Enumeration e = jar.entries();
                JarEntry entry;
                while (e.hasMoreElements()) {
                    entry = (JarEntry) e.nextElement();
                    if ((!entry.isDirectory()) &&
                            (entry.getName().endsWith(CONNECTOR_XML))) {
                        InputStream is = jar.getInputStream(entry);
                        return is;
                    }
                }
            }
View Full Code Here

Examples of java.util.jar.JarEntry

      new JarOutputStream(new FileOutputStream(jarFile), manifest);
  classes = _bcelClasses.elements();
  while (classes.hasMoreElements()) {
      final JavaClass clazz = (JavaClass)classes.nextElement();
      final String className = clazz.getClassName().replace('.','/');
      jos.putNextEntry(new JarEntry(className+".class"));
      final ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
      clazz.dump(out); // dump() closes it's output stream
      out.writeTo(jos);
  }
  jos.close();
View Full Code Here

Examples of java.util.jar.JarEntry

              filename = filename.substring(5);
            }
            JarFile jar = new JarFile(filename);
            for (Enumeration<JarEntry> entries = jar.entries(); entries
                .hasMoreElements();) {
              JarEntry entry = entries.nextElement();
              String name = entry.getName();
              addMatch("", baseName, bundleNames, baseFileName,
                  name);
            }
          } else {
            File jarDirectory = new File(jarFile).getParentFile();
View Full Code Here

Examples of java.util.jar.JarEntry

        jar = new JarFile(sourceFile);
        Enumeration<JarEntry> jarEntries = jar.entries();
        // Check in all jars - maybe we have static resources in custom jars
        // as well (not only in core)
        while (jarEntries.hasMoreElements()) {
          JarEntry jarEntry = jarEntries.nextElement();
          String jarEntryName = jarEntry.getName();
          if (jarEntryName.indexOf(File.separator + ClassPathStaticDispatcher.STATIC_DIR_NAME + File.separator) != -1) {
            if (!jarEntry.isDirectory()) {
              // Copy file from jar to static place
              // extract class name without trailing slashes
              staticDirPos = jarEntryName.indexOf(ClassPathStaticDispatcher.STATIC_DIR_NAME);
              String packageName = jarEntryName.substring(0, staticDirPos - 1);
              packageName = packageName.replace(File.separator, ".");
              String fileName = jarEntryName.substring(staticDirPos + ClassPathStaticDispatcher.STATIC_DIR_NAME.length());
              File targetFile = new File(classPathStaticDir, packageName + fileName);
              // Only do this if it does not already exist.
              // Use jar file last modified instead of jarEntry.getTime, seems to be unpredictable
              if (targetFile.exists() && targetFile.lastModified() >= sourceFile.lastModified()) {
                if (isLogDebugEnabled()) logDebug("Skipping static file from jar, filename::" + jarEntryName + " in jar::" + jar.getName()
                    + " - does already exist", null);
              } else {
                targetFile.getParentFile().mkdirs();
                BufferedInputStream inputStream = new BufferedInputStream(jar.getInputStream(jarEntry));
                BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile));
                FileUtils.copy(inputStream, outputStream, jarEntry.getSize());
                inputStream.close();
                outputStream.close();
                targetFile.setLastModified(sourceFile.lastModified());
                if (isLogDebugEnabled()) logDebug("Copying static file from jar, filename::" + jarEntryName + " in jar::" + jar.getName(),
                    null);
View Full Code Here

Examples of java.util.jar.JarEntry

            File langPackDir = I18nModule.LANG_PACKS_DIRECTORY;
            if (langPackDir.exists()) {
              File[] jars = langPackDir.listFiles(jarFileFilter);
              for (File file : jars) {
                JarFile jarFile = new JarFile(file);
                JarEntry jarEntry = jarFile.getJarEntry(relPath);
                if (jarEntry != null) {
                  is = jarFile.getInputStream(jarEntry);
                  if (logDebug) logDebug("loading LocalStrings from customizing jar::" + jarFile.getName() + " and relpath::" + relPath,
                      null);
                  break;
View Full Code Here

Examples of java.util.jar.JarEntry

          JarFile jar;
          try {
            jar = new JarFile(jarFile);
            Enumeration<JarEntry> jarEntries = jar.entries();
            while (jarEntries.hasMoreElements()) {
              JarEntry jarEntry = jarEntries.nextElement();
              String jarEntryName = jarEntry.getName();
              // search for core util in jar
              if (jarEntryName.indexOf(I18N_DIRNAME + "/" + I18nModule.LOCAL_STRINGS_FILE_PREFIX) != -1) {
                // remove beginning and tralining slash
                String rawBundleName = jarEntryName.substring(0, jarEntryName.indexOf(I18N_DIRNAME) - 1);
                String libBundleName = rawBundleName.replace("/", ".");
View Full Code Here

Examples of java.util.jar.JarEntry

    JarFile jar;
    try {
      jar = new JarFile(jarFile);
      Enumeration<JarEntry> jarEntries = jar.entries();
      while (jarEntries.hasMoreElements()) {
        JarEntry jarEntry = jarEntries.nextElement();
        String jarEntryName = jarEntry.getName();
        // check for executables
        if (checkForExecutables && (jarEntryName.endsWith("java") || jarEntryName.endsWith("class"))) { return new TreeSet<String>(); }
        // search for core util in jar
        if (jarEntryName.indexOf(I18nModule.getBrasatoFallbackBundle().replace(".", "/") + "/" + I18N_DIRNAME) != -1) {
          // don't add overlayLocales as selectable
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.