Examples of JarFile


Examples of java.util.jar.JarFile

      if (libDir.exists()) {
        // Second check for jar files
        File[] jarFiles = libDir.listFiles(jarFileFilter);
        for (File jarFile : jarFiles) {
          // check in all jars - don't know the name of the brasato jar
          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) {
View Full Code Here

Examples of java.util.jar.JarFile

   *          don't check or care
   * @return Set of language keys, can be empty but never null
   */
  public Set<String> sarchForAvailableLanguagesInJarFile(File jarFile, boolean checkForExecutables) {
    Set<String> foundLanguages = new TreeSet<String>();
    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
          // availableLanguages
          if (jarEntryName.indexOf("__") == -1 && jarEntryName.indexOf(I18nModule.LOCAL_STRINGS_FILE_PREFIX) != -1) {
            String lang = jarEntryName.substring(jarEntryName.indexOf(I18nModule.LOCAL_STRINGS_FILE_PREFIX)
                + I18nModule.LOCAL_STRINGS_FILE_PREFIX.length(), jarEntryName.lastIndexOf("."));
            foundLanguages.add(lang);
            if (isLogDebugEnabled()) logDebug("Adding lang::" + lang + " from filename::" + jarEntryName + " in jar::" + jar.getName(),
                null);
          }
        }
      }
    } catch (IOException e) {
View Full Code Here

Examples of java.util.jar.JarFile

   */
  public void copyLanguagesFromJar(File jarFile, Set<String> toCopyI18nKeys) {
    if (!I18nModule.isTransToolEnabled()) {
      throw new AssertException("Programming error - can only copy i18n files from a language pack to the source when in translation mode");
    }
    JarFile jar;
    try {
      jar = new JarFile(jarFile);
      Enumeration<JarEntry> jarEntries = jar.entries();
      while (jarEntries.hasMoreElements()) {
        JarEntry jarEntry = jarEntries.nextElement();
        String jarEntryName = jarEntry.getName();
        // Check if this entry is a language file
        for (String i18nKey : toCopyI18nKeys) {
          if (jarEntryName.endsWith(I18N_DIRNAME + "/" + I18nModule.LOCAL_STRINGS_FILE_PREFIX + i18nKey + I18nModule.LOCAL_STRINGS_FILE_POSTFIX)) {
            File targetBaseDir;
            // Special case: copy brasato files to brasato
            if (jarEntryName.startsWith(I18nModule.getBrasatoFallbackBundle().replace(".", "/"))) {
              if (i18nKey.equals("de") || i18nKey.equals("en")) {               
                targetBaseDir = new File(WebappHelper.getBrasatoSourcePath());               
              } else {
                targetBaseDir = I18nModule.getTransToolBrasatoLanguagesDir();                             
              }
            } else {
              if (i18nKey.equals("de") || i18nKey.equals("en")) {               
                targetBaseDir = new File(WebappHelper.getSourcePath());
              } else {
                targetBaseDir = I18nModule.getTransToolApplicationLanguagesDir();                           
              }
            }
            // Copy file
            File targetFile = new File(targetBaseDir, jarEntryName);
            targetFile.getParentFile().mkdirs();
            FileUtils.save(jar.getInputStream(jarEntry), targetFile);
             // Check that saved properties file is empty, if so remove it
            Properties props = new Properties();
            props.load(new FileInputStream(targetFile));
            if (props.size() == 0) {
              targetFile.delete();
View Full Code Here

Examples of java.util.jar.JarFile

    */
   static void generateJarSerialVersionUIDs(URL jar, TreeMap classVersionMap,
      ClassLoader cl, String pkgPrefix) throws IOException
   {
      String jarName = jar.getFile();
      JarFile jf = new JarFile(jarName);
      Enumeration entries = jf.entries();
      while( entries.hasMoreElements() )
      {
         JarEntry entry = (JarEntry) entries.nextElement();
         String name = entry.getName();
         if( name.endsWith(".class") && name.startsWith(pkgPrefix) )
         {
            name = name.substring(0, name.length() - 6);
            String classname = name.replace('/', '.');
            try
            {
               log.fine("Creating ClassVersionInfo for: "+classname);
               ClassVersionInfo cvi = new ClassVersionInfo(classname, cl);
               log.fine(cvi.toString());
               if( cvi.getSerialVersion() != 0 )
               {
                  ClassVersionInfo prevCVI = (ClassVersionInfo)
                     classVersionMap.put(classname, cvi);
                  if( prevCVI != null )
                  {
                     if( prevCVI.getSerialVersion() != cvi.getSerialVersion() )
                     {
                        log.severe("Found inconsistent classes, "
                           +prevCVI+" != "+cvi+", jar: "+jarName);
                     }
                  }
                  if( cvi.getHasExplicitSerialVersionUID() == false )
                  {
                     log.warning("No explicit serialVersionUID: "+cvi);
                  }
               }
            }
            catch(OutOfMemoryError e)
            {
               log.log(Level.SEVERE, "Check the MaxPermSize", e);
            }
            catch(Throwable e)
            {
               log.log(Level.FINE, "While loading: "+name, e);
            }
         }
      }
      jf.close();
   }
View Full Code Here

Examples of java.util.jar.JarFile

        classPath = classPath.replace(c, '.');
        addHelpPageToList(toBeChechedkFilName, classPath);

      // 2) Check for files within jars
      } else if (file.getName().endsWith(".jar")) {
        JarFile jar;
        try {
          jar = new JarFile(file);
          Enumeration<JarEntry> jarEntries = jar.entries();
          // Check in all jars - maybe we have context help files in
          // jar resources
          while (jarEntries.hasMoreElements()) {
            JarEntry jarEntry = jarEntries.nextElement();
            String jarEntryName = jarEntry.getName();
View Full Code Here

Examples of java.util.jar.JarFile

         if( file.renameTo(tmpFile) == false )
            throw new IOException("Failed to rename: "+file);

         try
         {
            this.jarFile = new JarFile(tmpFile);
         }
         catch(IOException e)
         {
            tmpFile.renameTo(file);
            throw new FileNotFoundException("Not a JarFile: "+file);
View Full Code Here

Examples of java.util.jar.JarFile

              }
            }
          }
          else // JAR file.
          {
            JarFile jarFile = new JarFile(locationFile);
            for(
              Enumeration<JarEntry> entries = jarFile.entries();
              entries.hasMoreElements();
              )
            {
              String jarEntryPath = ((JarEntry)entries.nextElement()).getName();
              if(
View Full Code Here

Examples of java.util.jar.JarFile

            if (path.length() > 4 && path.substring(path.length()-4).toLowerCase().equals(".jar"))
            {
                try
                {
                    JarFile jarFile = new JarFile(path);
                    JarEntry jarEntry = jarFile.getJarEntry(PLUGIN_CONFIG_RESOURCE);
                    if (jarEntry != null)
                    {
                        InputStream configStream = null;
                        try
                        {
                            configStream = jarFile.getInputStream(jarEntry);
                            configure(jarEntry.getName(), configStream);
                        }
                        finally
                        {
                            if (configStream != null)
View Full Code Here

Examples of java.util.jar.JarFile

        // probably existing at first place of path
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IPathVariableManager pathManager = workspace.getPathVariableManager();
        path = pathManager.resolvePath(path);

        JarFile jar = null;
        try {
            jar = new JarFile(path.toOSString());
        } catch (IOException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
            return null;
        }
        String fullClassName = getFullBytecodeName(classFile);
        if (fullClassName == null) {
            return null;
        }
        JarEntry jarEntry = jar.getJarEntry(fullClassName);
        if (jarEntry != null) {
            try {
                return jar.getInputStream(jarEntry);
            } catch (IOException e) {
                BytecodeOutlinePlugin.log(e, IStatus.ERROR);
            }
        }
        return null;
View Full Code Here

Examples of java.util.jar.JarFile

     * @return The JarFile
     */
    public static JarFile getJarFileForFilename(String filename)
    throws IOException
    {
        return new JarFile(getDecodedStringFromURLString(filename));
    }
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.