public static Document getDocument ( InputStream in ) throws AlipayApiException { Document doc = null ; try { DocumentBuilder builder = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) ; doc = builder . parse ( in ) ; } catch ( ParserConfigurationException e ) { throw new AlipayApiException ( e ) ; } catch ( SAXException e ) { throw new AlipayApiException ( "XML_PARSE_ERROR" , e ) ; } catch ( IOException e ) { throw new AlipayApiException ( "XML_READ_ERROR" , e ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { // nothing to do } } } return doc ; }
Parses the content of the given stream as an XML document .