本文整理汇总了Java中java.net.URLClassLoader.findResources方法的典型用法代码示例。如果您正苦于以下问题:Java URLClassLoader.findResources方法的具体用法?Java URLClassLoader.findResources怎么用?Java URLClassLoader.findResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URLClassLoader
的用法示例。
在下文中一共展示了URLClassLoader.findResources方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDir
import java.net.URLClassLoader; //导入方法依赖的package包/类
public static void testDir()throws Exception
{
File f=new File("C:/Users/Administrator/git/util4j/util4j/target/classes");
URL url=f.toURI().toURL();
URL[] urls=new URL[]{url};
URLClassLoader loader=new URLClassLoader(urls);
// loader.close();
Class c1=loader.loadClass("net.jueb.util4j.math.CombinationUtil");
System.out.println(c1);
Class c2=loader.loadClass("net.jueb.util4j.math.CombinationUtil$CombinationController");
System.out.println(c2);
Class c3=loader.loadClass("net.jueb.util4j.math.CombinationUtil$ForEachByteIndexController");
System.out.println(c3);
Enumeration<URL> ss=loader.findResources("*.class");
System.out.println(ss.hasMoreElements());
CombinationUtil c22=(CombinationUtil) c1.newInstance();
System.out.println(c22);
loader.close();
c1=loader.loadClass("net.jueb.util4j.math.CombinationUtil");
System.out.println(c1);
}
示例2: scanEpisodeFile
import java.net.URLClassLoader; //导入方法依赖的package包/类
/**
* Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
*/
public void scanEpisodeFile(File jar) throws BadCommandLineException {
try {
URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
addBindFile(new InputSource(url.toExternalForm()));
}
} catch (IOException e) {
throw new BadCommandLineException(
Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
}
}
示例3: scanEpisodeFile
import java.net.URLClassLoader; //导入方法依赖的package包/类
/**
* Finds the {@code META-INF/sun-jaxb.episode} file to add as a binding customization.
*
* @param jar
* @throws com.sun.tools.internal.xjc.BadCommandLineException
*/
public void scanEpisodeFile(File jar) throws BadCommandLineException {
try {
URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
addBindFile(new InputSource(url.toExternalForm()));
}
} catch (IOException e) {
throw new BadCommandLineException(
Messages.format(Messages.FAILED_TO_LOAD, jar, e.getMessage()), e);
}
}