@ NotNull public static Document parseDocument ( @ NotNull final DocumentBuilder builder , @ NotNull final InputStream inputStream ) { Contract . requireArgNotNull ( "builder" , builder ) ; Contract . requireArgNotNull ( "inputStream" , inputStream ) ; try { return builder . parse ( inputStream ) ; } catch ( final SAXException | IOException ex ) { throw new RuntimeException ( "Failed to parse XML" , ex ) ; } }
Parse the document and wraps checked exceptions into runtime exceptions .