Java 8 JarURLConnection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JarURLConnection class.

This code example shows how to use the following methods: getJarFile, connect, setAllowUserInteraction, setDoInput, setDoOutput
log.debug("JarHolder: attempting to connect to " + urlpath);
            } 
            URL url = new URL( urlpath );
            conn = (JarURLConnection) url.openConnection();
            conn.setAllowUserInteraction(false);
            conn.setDoInput(true);
            conn.setDoOutput(false);
            conn.connect();
            theJar = conn.getJarFile();
        } 
        catch (IOException ioe)
        { 
            String msg = "JarHolder: error establishing connection to JAR at \""
                         + urlpath + "\"";
            log.error(msg, ioe);
            throw new VelocityException(msg, ioe);
        } 
    } 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getJarEntry, getJarFile, getInputStream, setUseCaches
        Support_Resources.copyFile(resources, null, "hyts_att.jar");
        File file = new File(resources.toString() + "/hyts_att.jar");
        URL url = new URL("jar:file:" + file.getPath() + "!/HasAttributes.txt");
 
        JarURLConnection connection = (JarURLConnection) url.openConnection();
        connection.setUseCaches(false);
        connection.getInputStream();
        InputStream in = connection.getInputStream();
        JarFile jarFile1 = connection.getJarFile();
        JarEntry jarEntry1 = connection.getJarEntry();
        in.read();
        in.close();
        JarFile jarFile2 = connection.getJarFile();
        JarEntry jarEntry2 = connection.getJarEntry();
        assertSame(jarFile1, jarFile2);
        assertSame(jarEntry1, jarEntry2);
 
        try { 
            connection.getInputStream();
            fail("should throw IllegalStateException");

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getJarFile, connect, setUseCaches
    private JarFile getJarFile(URL jarFileUrl) throws IOException {
	JarFile jarFile = null;
 
	if (jarFileUrl != null) {
	    JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
	    conn.setUseCaches(false);
	    conn.connect();
	    jarFile = conn.getJarFile();
	} 
 
	return jarFile;
    } 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getJarEntry, getJarFile
        throw new IOException("Could not find file: " + fileName);
      } 
    } 
    if (url.getProtocol().equals("jar")) {
      JarURLConnection jc = (JarURLConnection) url.openConnection();
      JarFile f = jc.getJarFile();
      JarEntry entry = jc.getJarEntry();
      JarFileModule parent = new JarFileModule(f);
      return new NestedJarFileModule(parent, entry);
    } else if (url.getProtocol().equals("rsrc")) {
      return new ResourceJarFileModule(url);
    } else { 
      String filePath = filePathFromURL(url);
      return new JarFileModule(new JarFile(filePath, false));
    } 
  } 
 
  /** 
   * Properly creates the String file name of a {@link URL}. This works around a 
   * bug in the Sun implementation of {@link URL#getFile()}, which doesn't 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getJarFile, connect, setUseCaches
     
    @Override 
    public JarFile getJarFile() throws IOException {
        URL jarFileUrl = new URL("jar:" + jarUrl + "!/");
        JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
        conn.setUseCaches(false);
        conn.connect();
        return conn.getJarFile();
    } 
        
    @Override 
    public String getUrl() {
        return jarUrl;
    } 
     
    @Override 
    public URL getEntry(String name) {
        try { 
            return new URL("jar:" + jarUrl + "!/" + name);
        } catch (MalformedURLException e) {
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 JarURLConnection Methods: