Package java.net

Examples of java.net.JarURLConnection


        JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile));
        out.putNextEntry(new ZipEntry("test"));
        out.closeEntry();
        out.close();

        JarURLConnection conn = (JarURLConnection) new URL("jar:file:"
                + jarFile.getAbsolutePath().replaceAll(" ", "%20") + "!/")
                .openConnection();
        conn.getJarFile().entries();
    }
View Full Code Here


        File resources = Support_Resources.createTempFolder();
        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);
        InputStream in = connection.getInputStream();
        JarFile jarFile1 = connection.getJarFile();
        JarEntry jarEntry1 = connection.getJarEntry();
        byte[] data = new byte[1024];
        while (in.read(data) >= 0)
            ;
        in.close();
        JarFile jarFile2 = connection.getJarFile();
        JarEntry jarEntry2 = connection.getJarEntry();
        assertSame(jarFile1, jarFile2);
        assertSame(jarEntry1, jarEntry2);
       
        try {
            connection.getInputStream();
            fail("should throw IllegalStateException");
        } catch (IllegalStateException e) {
            // expected
        }
    }
View Full Code Here

    try {
      File resources = Support_Resources.createTempFolder();
      Support_Resources.copyFile(resources, null, "hyts_att.jar");
      URL fUrl1 = new URL("jar:file:" + resources.getPath()
          + "/hyts_att.jar!/");
      JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection();
      map = con1.getRequestProperties();
      assertNotNull(map);
      assertEquals(0, map.size());
      try {
        // the map should be unmodifiable
        map.put("hi", "bye");
View Full Code Here

    try {
      File resources = Support_Resources.createTempFolder();
      Support_Resources.copyFile(resources, null, "hyts_att.jar");
      URL fUrl1 = new URL("jar:file:" + resources.getPath()
          + "/hyts_att.jar!/");
      JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection();
      headers = con1.getHeaderFields();
      assertNotNull(headers);
      assertEquals(0, headers.size());
      try {
        // the map should be unmodifiable
        headers.put("hi", "bye");
View Full Code Here

            }
        }
    }

    private static void readJarEntries(URL location, String basePath, Map<String, URL> resources) throws IOException {
        JarURLConnection conn = (JarURLConnection) location.openConnection();
        JarFile jarfile = null;
        jarfile = conn.getJarFile();

        Enumeration<JarEntry> entries = jarfile.entries();
        while (entries != null && entries.hasMoreElements()) {
            JarEntry entry = entries.nextElement();
            String name = entry.getName();
View Full Code Here

        }
    }

    //read directories in the jar that start with the basePath
    private static void readJarDirectoryEntries(URL location, String basePath, Set<String> resources) throws IOException {
        JarURLConnection conn = (JarURLConnection) location.openConnection();
        JarFile jarfile = null;
        jarfile = conn.getJarFile();

        Enumeration<JarEntry> entries = jarfile.entries();
        while (entries != null && entries.hasMoreElements()) {
            JarEntry entry = entries.nextElement();
            String name = entry.getName();
View Full Code Here

                    * used, getJarFile() will throw an exception if the
                    * entry doesn't exist.
                    */
                    URL jarURL = ((JarURLConnection) currentUrl.openConnection()).getJarFileURL();
                    try {
                        JarURLConnection juc = (JarURLConnection) new URL("jar", "", jarURL.toExternalForm() + "!/").openConnection();
                        jarFile = juc.getJarFile();
                    } catch (IOException e) {
                        // Don't look for this jar file again
                        search[i] = null;
                        throw e;
                    }
View Full Code Here

        private InputStream is;

        public SafeURLInputStream(URL url) throws IOException {
            String protocol = url.getProtocol();
            if (protocol != null && (protocol.equals("jar"))) {
                JarURLConnection connection = (JarURLConnection)url.openConnection();
                // We cannot use cache
                connection.setUseCaches(false);
                try {
                    is = connection.getInputStream();
                } catch (IOException e) {
                    throw e;
                }
                jarFile = connection.getJarFile();
            } else {
                URLConnection connection = url.openConnection();
                connection.setUseCaches(false);
                is = connection.getInputStream();
            }
        }
View Full Code Here

                    classNames.addAll(jar(location));
                } else if ("file".equals(location.getProtocol())) {
                    try {
                        // See if it's actually a jar
                        URL jarUrl = new URL("jar", "", location.toExternalForm() + "!/");
                        JarURLConnection juc = (JarURLConnection) jarUrl.openConnection();
                        juc.getJarFile();
                        classNames.addAll(jar(jarUrl));
                    } catch (IOException e) {
                        classNames.addAll(file(location));
                    }
                }
View Full Code Here

        InputStream            istream;
        InputSource            isource;
        DocumentBuilderFactory builderFactory;
        DocumentBuilder        builder;
        JarURLConnection       jarConnection;
        JarEntry               jarentry;
        JarFile                jarfile;
        URL                    url;

        converterInfoList = new Vector();
        jarfilename       = jar;

        // Get Jar via URL
        //
        url               = new URL("jar:" + jar + "!/META-INF/converter.xml");
        jarConnection     = (JarURLConnection)url.openConnection();
        jarentry          = jarConnection.getJarEntry();
        jarfile           = jarConnection.getJarFile();

        // Build the InputSource
        //
        istream           = jarfile.getInputStream(jarentry);
        isource           = new InputSource(istream);
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.