@Test void testResourceReadError() throws IOException { final InputStream resource = Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/trellisldp/app/banner.txt"); resource.close(); assertDoesNotThrow(() -> AppUtils.readResource(resource)); }
static String readResource(final InputStream resourceStream) { if (resourceStream != null) { try (final InputStreamReader inputStreamReader = new InputStreamReader(resourceStream, UTF_8); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return bufferedReader.lines().collect(joining(String.format("%n"))); } catch (final IOException | UncheckedIOException ex) { LOGGER.error("Error reading banner resource: {}", ex.getMessage()); } } return ""; }
AppUtils { static String readResource(final InputStream resourceStream) { if (resourceStream != null) { try (final InputStreamReader inputStreamReader = new InputStreamReader(resourceStream, UTF_8); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return bufferedReader.lines().collect(joining(String.format("%n"))); } catch (final IOException | UncheckedIOException ex) { LOGGER.error("Error reading banner resource: {}", ex.getMessage()); } } return ""; } }
AppUtils { static String readResource(final InputStream resourceStream) { if (resourceStream != null) { try (final InputStreamReader inputStreamReader = new InputStreamReader(resourceStream, UTF_8); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return bufferedReader.lines().collect(joining(String.format("%n"))); } catch (final IOException | UncheckedIOException ex) { LOGGER.error("Error reading banner resource: {}", ex.getMessage()); } } return ""; } private  AppUtils(); }
AppUtils { static String readResource(final InputStream resourceStream) { if (resourceStream != null) { try (final InputStreamReader inputStreamReader = new InputStreamReader(resourceStream, UTF_8); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return bufferedReader.lines().collect(joining(String.format("%n"))); } catch (final IOException | UncheckedIOException ex) { LOGGER.error("Error reading banner resource: {}", ex.getMessage()); } } return ""; } private  AppUtils(); static void printBanner(final String name, final String resource); }
AppUtils { static String readResource(final InputStream resourceStream) { if (resourceStream != null) { try (final InputStreamReader inputStreamReader = new InputStreamReader(resourceStream, UTF_8); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return bufferedReader.lines().collect(joining(String.format("%n"))); } catch (final IOException | UncheckedIOException ex) { LOGGER.error("Error reading banner resource: {}", ex.getMessage()); } } return ""; } private  AppUtils(); static void printBanner(final String name, final String resource);  }