Package java.net

Examples of java.net.URLClassLoader.findResource()


  private String readAppVersion() throws IOException {
    URLClassLoader cl = (URLClassLoader) getClass().getClassLoader();
    String ret = new String();
   
    try {
      URL url = cl.findResource("META-INF/MANIFEST.MF");
      Manifest mf = new Manifest(url.openStream());
      Attributes atts = mf.getMainAttributes();
      String impVersion = atts.getValue("Implementation-Version");
      String impBuild = atts.getValue("Implementation-Build");
     
View Full Code Here


        URL[] urls = new URL[1];
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_11.jar");
        URLClassLoader ucl = URLClassLoader.newInstance(urls, null);

        URL resURL = ucl.findResource("Test.txt");
        URL reference = new URL("jar:file:/" + resPath.replace('\\', '/')
                + "/JarIndex/hyts_14.jar!/Test.txt");
        assertEquals("Resource not found: " + resURL + " ref: " + reference,
                reference, resURL);
View Full Code Here

        }

        Support_Resources.copyFile(resources, "JarIndex", "hyts_22-new.jar");
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_22-new.jar");
        ucl = URLClassLoader.newInstance(urls, null);
        assertNotNull("Cannot find resource", ucl.findResource("cpack/"));
        Support_Resources.copyFile(resources, "JarIndex", "hyts_11.jar");
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_31.jar");
        ucl = URLClassLoader.newInstance(urls, null);

        try {
View Full Code Here

        Enumeration en = urlClassloader.findResources("bpack/");
        assertTrue(en.hasMoreElements());
        URL expected = new URL("jar:file:/" + resPath.replace('\\', '/')
                + "/JarIndex/hyts_22.jar!/bpack/");
        assertEquals(expected, (URL) en.nextElement());
        assertEquals(expected, urlClassloader.findResource("bpack/"));
    }

    /**
     * @tests java.net.URLClassLoader#getResource(java.lang.String)
     */
 
View Full Code Here

    /**
     * Regression for Harmony-2237
     */
    public void test_getResource() throws Exception {
        URLClassLoader urlLoader = getURLClassLoader();
        assertNull(urlLoader.findResource("XXX")); //$NON-NLS-1$
    }

    private static URLClassLoader getURLClassLoader() {
        String classPath = System.getProperty("java.class.path");
        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
View Full Code Here

          e.printStackTrace();
        }
        if (null == checker ||
        // || null != checker.findResource("java/lang/Object.class")
        // //$NON-NLS-1$
            null != checker.findResource("org/apache/uima/impl/UIMAFramework_impl.class")) { //$NON-NLS-1$
          continue;
        }
      }
      if (result.length() > 0)
        result = result.append(PATH_SEPARATOR);
View Full Code Here

                    "/WEB-INF/beans.xml",
                    "/META-INF/beans.xml",
                };

                for (final String path : paths) {
                    if (loader.findResource(path) != null) {
                        return true;
                    }
                }
            } catch (final Exception e) {
                // no-op
View Full Code Here

          e.printStackTrace();
        }
        if (null == checker ||
        // || null != checker.findResource("java/lang/Object.class")
        // //$NON-NLS-1$
            null != checker.findResource("org/apache/uima/impl/UIMAFramework_impl.class")) { //$NON-NLS-1$
          continue;
        }
      }
      if (result.length() > 0)
        result = result.append(PATH_SEPARATOR);
View Full Code Here

      final URL url = pluginFile.toURI().toURL();

      pluginClassLoader = new URLClassLoader(new URL[] { url });

      // LOAD PLUGIN.JSON FILE
      final URL r = pluginClassLoader.findResource("plugin.json");
      if (r == null) {
        OLogManager.instance().error(this, "Plugin definition file ('plugin.json') is not found for dynamic plugin '%s'",
            pluginName);
        throw new IllegalArgumentException(String.format(
            "Plugin definition file ('plugin.json') is not found for dynamic plugin '%s'", pluginName));
View Full Code Here

                    "/WEB-INF/beans.xml",
                    "/META-INF/beans.xml",
                };

                for (final String path : paths) {
                    if (loader.findResource(path) != null) {
                        return true;
                    }
                }
            } catch (final Exception e) {
                // no-op
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.