public static Document resourceFileToXMLDocument ( final String location , final String fileName ) { if ( location == null || fileName == null ) return null ; final InputStream in = ResourceUtilities . class . getResourceAsStream ( location + fileName ) ; if ( in == null ) return null ; final DocumentBuilderFactory dbFactory = DocumentBuilderFactory . newInstance ( ) ; final DocumentBuilder dBuilder ; Document doc = null ; try { dBuilder = dbFactory . newDocumentBuilder ( ) ; doc = dBuilder . parse ( in ) ; } catch ( Exception e ) { LOG . error ( "Failed to parse the resource as XML." , e ) ; } finally { try { in . close ( ) ; } catch ( IOException e ) { LOG . error ( "Failed to close the InputStream" , e ) ; } } return doc ; }
Reads a resource file and converts it into a XML based Document object .