@@ -81,30 +81,22 @@ public class XML {
8181 "scijava.log.level" ));
8282
8383 /** Parses XML from the given file. */
84- public XML (final File file ) throws ParserConfigurationException , SAXException ,
85- IOException
86- {
84+ public XML (final File file ) throws IOException {
8785 this (file .getAbsolutePath (), loadXML (file ));
8886 }
8987
9088 /** Parses XML from the given URL. */
91- public XML (final URL url ) throws ParserConfigurationException , SAXException ,
92- IOException
93- {
89+ public XML (final URL url ) throws IOException {
9490 this (url .getPath (), loadXML (url ));
9591 }
9692
9793 /** Parses XML from the given input stream. */
98- public XML (final InputStream in ) throws ParserConfigurationException ,
99- SAXException , IOException
100- {
94+ public XML (final InputStream in ) throws IOException {
10195 this (null , loadXML (in ));
10296 }
10397
10498 /** Parses XML from the given string. */
105- public XML (final String s ) throws ParserConfigurationException , SAXException ,
106- IOException
107- {
99+ public XML (final String s ) throws IOException {
108100 this (null , loadXML (s ));
109101 }
110102
@@ -262,34 +254,41 @@ public static ArrayList<Element> elements(final Element el,
262254 // -- Helper methods --
263255
264256 /** Loads an XML document from the given file. */
265- private static Document loadXML (final File file )
266- throws ParserConfigurationException , SAXException , IOException
267- {
268- return createBuilder ().parse (file .getAbsolutePath ());
257+ private static Document loadXML (final File file ) throws IOException {
258+ try {
259+ return createBuilder ().parse (file .getAbsolutePath ());
260+ }
261+ catch (ParserConfigurationException | SAXException exc ) {
262+ throw new IOException (exc );
263+ }
269264 }
270265
271266 /** Loads an XML document from the given URL. */
272- private static Document loadXML (final URL url )
273- throws ParserConfigurationException , SAXException , IOException
274- {
267+ private static Document loadXML (final URL url ) throws IOException {
275268 try (final InputStream in = url .openStream ()) {
276269 final Document document = loadXML (in );
277270 return document ;
278271 }
279272 }
280273
281274 /** Loads an XML document from the given input stream. */
282- protected static Document loadXML (final InputStream in )
283- throws ParserConfigurationException , SAXException , IOException
284- {
285- return createBuilder ().parse (in );
275+ protected static Document loadXML (final InputStream in ) throws IOException {
276+ try {
277+ return createBuilder ().parse (in );
278+ }
279+ catch (ParserConfigurationException | SAXException exc ) {
280+ throw new IOException (exc );
281+ }
286282 }
287283
288284 /** Loads an XML document from the given input stream. */
289- protected static Document loadXML (final String s )
290- throws ParserConfigurationException , SAXException , IOException
291- {
292- return createBuilder ().parse (new ByteArrayInputStream (s .getBytes ()));
285+ protected static Document loadXML (final String s ) throws IOException {
286+ try {
287+ return createBuilder ().parse (new ByteArrayInputStream (s .getBytes ()));
288+ }
289+ catch (ParserConfigurationException | SAXException exc ) {
290+ throw new IOException (exc );
291+ }
293292 }
294293
295294 /** Creates an XML document builder. */
0 commit comments