Package java.net

Examples of java.net.JarURLConnection


    // workaround for bug where cached applet loader does not have certificates!?
    if (certificate == null) {
      URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();

      // manually load the certificate
      JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
      jurl.setDefaultUseCaches(true);
      certificate = jurl.getCertificates();
    }
   
    for (int i = urlList.length - nativeJarCount; i < urlList.length; i++) {
     
      // if a new native jar was not downloaded, no extracting needed
View Full Code Here


   protected Manifest findManifest(URL url) throws Exception
   {
      URLConnection conn = url.openConnection();
      if (conn instanceof JarURLConnection)
      {
         JarURLConnection jarConn = (JarURLConnection)conn;
         return jarConn.getManifest();
      }
      else
      {
         File parent = new File(url.toURI());
         File child = new File(parent, JarFile.MANIFEST_NAME);
View Full Code Here

                if (manifest.getPath().startsWith("http://"))
                {
                  // protocol formats:
                  //     jar:http:<path>!<manifest-file>, zip:http:<path>!<manifest-file>
                  // e.g jar:http://<host>[:port]/[app-path]/jpox-java5.jar!/plugin.xml
                  JarURLConnection jarConnection = (JarURLConnection) manifest.openConnection();
                  URL url = jarConnection.getJarFileURL();
                  mf = jarConnection.getManifest();
                  if (mf == null)
                  {
                      return null;
                  }
                  return registerBundle(mf, url);
View Full Code Here

                    }
                }

            } else if ("jar".equals(url.getProtocol())) {

                JarURLConnection conn = (JarURLConnection) url.openConnection();

                JarFile jar = conn.getJarFile();

                Enumeration<JarEntry> en = jar.entries();

                while (en.hasMoreElements()) {
                    JarEntry jarEntry = en.nextElement();
View Full Code Here

                if (manifest.getPath().startsWith("http://"))
                {
                  // protocol formats:
                  //     jar:http:<path>!<manifest-file>, zip:http:<path>!<manifest-file>
                  // e.g jar:http://<host>[:port]/[app-path]/jpox-java5.jar!/plugin.xml
                  JarURLConnection jarConnection = (JarURLConnection) manifest.openConnection();
                  URL url = jarConnection.getJarFileURL();
                  mf = jarConnection.getManifest();
                  if (mf == null)
                  {
                      return null;
                  }
                  return registerBundle(mf, url);
View Full Code Here

   * We don't use getContentEncoding() on the URL connection, because it might leave open streams behind.
   * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=117890
   */
  protected String getURLContents(String docUrlValue) throws JavaModelException {
    InputStream stream = null;
    JarURLConnection connection2 = null;
    try {
      URL docUrl = new URL(docUrlValue);
      URLConnection connection = docUrl.openConnection();
      if (connection instanceof JarURLConnection) {
        connection2 = (JarURLConnection) connection;
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=156307
        connection.setUseCaches(false);
      }
      stream = new BufferedInputStream(connection.getInputStream());
      String encoding = connection.getContentEncoding();
      byte[] contents = org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, connection.getContentLength());
      if (encoding == null) {
        int index = getIndexOf(contents, CONTENT_TYPE, 0);
        if (index != -1) {
          index = getIndexOf(contents, CONTENT, index);
          if (index != -1) {
            int offset = index + CONTENT.length;
            int index2 = getIndexOf(contents, CLOSING_DOUBLE_QUOTE, offset);
            if (index2 != -1) {
              final int charsetIndex = getIndexOf(contents, CHARSET, offset);
              if (charsetIndex != -1) {
                int start = charsetIndex + CHARSET.length;
                encoding = new String(contents, start, index2 - start, "UTF-8"); //$NON-NLS-1$
              }
            }
          }
        }
      }
      try {
        if (encoding == null) {
          encoding = this.getJavaProject().getProject().getDefaultCharset();
        }
      } catch (CoreException e) {
        // ignore
      }
      if (contents != null) {
        if (encoding != null) {
          return new String(contents, encoding);
        } else {
          // platform encoding is used
          return new String(contents);
        }
      }     
     } catch (MalformedURLException e) {
       throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC, this));
    } catch (FileNotFoundException e) {
      // ignore. see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=120559
    } catch(IOException e) {
      StringWriter stringWriter = new StringWriter();
      PrintWriter writer = new PrintWriter(stringWriter);
      e.printStackTrace(writer);
      writer.flush();
      writer.close();
      throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC, this, String.valueOf(stringWriter.getBuffer())));
    } finally {
      if (stream != null) {
        try {
          stream.close();
        } catch (IOException e) {
          // ignore
        }
      }
      if (connection2 != null) {
        try {
          connection2.getJarFile().close();
        } catch(IOException e) {
          // ignore
        } catch(IllegalStateException e) {
          /*
           * ignore. Can happen in case the stream.close() did close the jar file
View Full Code Here

        if (rc == null) {
            // guess the home from the location of the jar
            URL url = mainClass.getClassLoader().getResource(mainClass.getName().replace(".", "/") + ".class");
            if (url != null) {
                try {
                    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
                    url = jarConnection.getJarFileURL();
                    rc = new File(new URI(url.toString())).getCanonicalFile().getParentFile().getParentFile();
                } catch (Exception ignored) {
                }
            }
        }
View Full Code Here

       
        // guess from the location of the jar
        URL url = JAXWSToolsCLI.class.getClassLoader().getResource("META-INF/startup-jar");
        if (url != null) {
            try {
                JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
                url = jarConnection.getJarFileURL();

                URI baseURI = new URI(url.toString()).resolve("..");
                File dir = new File(baseURI);               
                return dir.getAbsolutePath();
            } catch (Exception ignored) {
View Full Code Here

            } catch (IOException e) {
                return COLLECTION;
            }
        } else {
            URL jarURL = new URL("jar:" + url.toString() + "!/");
            JarURLConnection jarConnection = (JarURLConnection) jarURL.openConnection();
            try {
                jarConnection.getManifest();
                return PACKED_ARCHIVE;
            } catch (ZipException e) {
                return RESOURCE;
            }
        }
View Full Code Here

        }

        // extract the manifest
        Manifest manifest;
        try {
            JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
            manifest = jarConnection.getManifest();
        } catch (IOException e) {
            System.err.println("Startup jar does not contain a manifest: " + url);
            System.exit(1);
            throw new AssertionError();
        }
View Full Code Here

TOP

Related Classes of java.net.JarURLConnection

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.