Package java.util.jar

Examples of java.util.jar.JarFile$MyJarEntry


      // The jar must be there
      File file = new File(userDir, "jboss-messaging.jar");
      assertTrue(file.exists());

      // Open the jar and load MANIFEST.MF
      JarFile jar = new JarFile(file);
      Manifest manifest = jar.getManifest();
     
      // Open a connection and get ConnectionMetaData
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
      Connection conn = cf.createConnection();
View Full Code Here


     *                if there is an exception while opening the plugin
     */
    public PluginJAR(String location) throws IOException {
        this.location = location;

        jar = new JarFile(location);

        loadContents();
    }
View Full Code Here

        JarEntry entry = null;
        try {
            entry = jar.getJarEntry(name);
        } catch (IllegalStateException ex) {
            try {
                jar = new JarFile(location);
                entry = jar.getJarEntry(name);
            } catch (IllegalStateException e) {
            } catch (IOException e) {
            }
        }
View Full Code Here

            WrapperManager.stop( 1 );
            return// Will not get here
        }
        File parent = file.getParentFile();

        JarFile jarFile;
        try
        {
            jarFile = new JarFile( file );
        }
        catch ( IOException e )
        {
            m_outError.println( WrapperManager.getRes().getString(
                    "Unable to open the jar file {0} : {1}", args[0], e ) );
            showUsage();
            WrapperManager.stop( 1 );
            return// Will not get here
        }
       
        Manifest manifest;
        try
        {
            manifest = jarFile.getManifest();
        }
        catch ( IOException e )
        {
            m_outError.println( WrapperManager.getRes().getString(
                    "Unable to access the jar''s manifest file {0} : {1}", args[0], e ) );
View Full Code Here

     *         does not exist.
     */
    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;
                    }
                }
            }
            else {
View Full Code Here

    public static File unpackPluginXML(File f) {
        InputStream in = null;
        OutputStream out = null;

        try {
            JarFile jar = new JarFile(f);
            ZipEntry entry = jar.getEntry(PLUGIN_XML_FILE);
            if (entry == null) {
                return null;
            }
            File dest = File.createTempFile("jabref_plugin", ".xml");
            dest.deleteOnExit();
           
            in = new BufferedInputStream(jar.getInputStream(entry));
            out = new BufferedOutputStream(new FileOutputStream(dest));
            byte[] buffer = new byte[2048];
            for (;;)  {
                int nBytes = in.read(buffer);
                if (nBytes <= 0) break;
View Full Code Here

            String filename = jarFile.substring(0, jarFile.length()
                - resourceName.length() - 2);
            if (filename.startsWith("file:")) {
              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);
View Full Code Here

          targetFile.setLastModified(sourceFile.lastModified());
          if (isLogDebugEnabled()) logDebug("Copying static file from filename::" + sourceFile, null);
        }
       
      } else if (sourceFile.getName().endsWith(".jar")) {
        JarFile jar;
        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

            // Rel path must not start with "!/", remove it
            String relPath  = fileName.substring(pathDelim + 2);
            try {
              // Get last modified and file size form jar entry
              File jarFile = new File(jarPath);
              JarFile jar = new JarFile(jarFile);
              ZipEntry entry = jar.getEntry(relPath);
              if (entry == null) {
                logWarn("jar resource at location '"+location+"' and package " + packageName + " was not found, could not resolve entry relPath::" + relPath, null);
              } else {
                size = new Long(entry.getSize());
                // Last modified of jar - getTime on jar entry is not stable
View Full Code Here

          if (is == null) {
            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

TOP

Related Classes of java.util.jar.JarFile$MyJarEntry

Copyright © 2018 www.massapicom. 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.