我正在尝试读取xsd文件来验证模式。尝试读取jar文件时出错
我的模式是在位置x/y/z/test.xsd
我的课外阅读这个文件也是x/y/z/ReadSchema.java
两个有包装在我的罐子。
我想读取这个文件在ReadSchema.java
像下面那样的名字是test.xsd
但是url返回为null?
我在做什么错在这里?
private static URL getURLForName(String name)
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getResource(name);
return url;
}
检查:http://stackoverflow.com/questions/14739550/what-is-the-difference-between-getclass-getclassloader- getresource-and-get – rmalchow 2013-04-22 08:06:11
和这个:http://stackoverflow.com/questions/676250/different-ways-of-loading-a-file-as-an-inputstream – rmalchow 2013-04-22 08:06:27
我不确定我会称它为绝对的路径。 – maba 2013-04-22 08:14:18