Private static Document loadBundle (final ClassLoader loader, final String bundleName ){
// Next search for a Properties file.
InputStream stream = (InputStream) java. security. AccessController. doPrivileged (
New java. security. PrivilegedAction (){
Public Object run (){
If (loader! = Null ){
Return loader. getResourceAsStream (bundleName );
} Else {
Return ClassLoader. getSystemResourceAsStream (bundleName );
}
}
}
);
If (stream! = Null ){
Try {
// Create a builder factory
DocumentBuilderFactory factory = DocumentBuilderFactory. newInstance ();
Factory. setValidating (false );
// Create the builder and parse the file
Document doc = factory. newDocumentBuilder (). parse (stream );
Return doc;
} Catch (SAXException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
} Catch (IOException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
} Catch (ParserConfigurationException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
} Finally {
Try {
Stream. close ();
} Catch (Exception e ){
// To avoid propagating an IOException back into the caller
// (I'm assuming this is never going to happen, and if it does,
// I'm obeying the precedent of swallowing exceptions set by
// Existing code above)
}
}
}
Return null;
}