/** * Create an array of {@link InputStream}s from the provided list of {@link URI}s. * * @param uris the URIs to open as input streams * @return an array of input streams * @throws IOException if there was an error opening the streams */ public static InputStream[] openStreams(final URI... uris) throws IOException { final InputStream[] schemas = new InputStream[uris.length]; for (int pos = 0; pos < uris.length; pos++) { try { schemas[pos] = openStream(uris[pos]); } catch (final Exception e) { int closedStreamsCount = closeStreams(schemas); LOGGER.info("Closed {} input streams", closedStreamsCount); throw e; } } return schemas; }
inputStreams.add(openStream(clazz, file)); } catch (final Exception e) { int closedStreamsCount = closeStreams(inputStreams.toArray(new InputStream[inputStreams.size()])); LOGGER.info(String.format("Closed %s input streams", closedStreamsCount));