load document from resource

This commit is contained in:
Dmitry Avdeev
2010-04-23 16:03:23 +04:00
parent 9a28ca404b
commit c801fa60b4
2 changed files with 10 additions and 3 deletions
@@ -284,9 +284,9 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
if (ourShadowInstance == null) {
ourShadowInstance = new ApplicationInfoImpl();
try {
Document doc = JDOMUtil.loadDocument(ApplicationInfoImpl.class.getResourceAsStream(IDEA_PATH +
ApplicationNamesInfo.getComponentName() +
XML_EXTENSION));
Document doc = JDOMUtil.loadDocument(ApplicationInfoImpl.class, IDEA_PATH +
ApplicationNamesInfo.getComponentName() +
XML_EXTENSION);
ourShadowInstance.readExternal(doc.getRootElement());
}
catch (Exception e) {
@@ -336,6 +336,13 @@ public class JDOMUtil {
}
}
@NotNull
public static Document loadDocument(Class clazz, String reaource) throws JDOMException, IOException {
InputStream stream = clazz.getResourceAsStream(reaource);
if (stream == null) throw new FileNotFoundException(reaource);
return loadDocument(stream);
}
@NotNull
public static Document loadDocument(URL url) throws JDOMException, IOException {
return loadDocument(URLUtil.openStream(url));