/** * Reads all lines from a stream and closes the stream. * * @param stream * the input stream */ public static String readAllLines(InputStream stream) throws IOException { return readAllLines(stream, Integer.MAX_VALUE); }
/** * Reads all lines from a stream and closes the stream. * * @param stream * the input stream */ public static String readAllLines(InputStream stream) throws IOException { return readAllLines(stream, Integer.MAX_VALUE); }
private String loadTCKTimestamp() { InputStream stream = getClass().getResourceAsStream(TCK_BUILD_TIMESTAMP); if (stream != null) { try { return IOUtils.readAllLines(stream, 1000); } catch (IOException e) { return ""; } finally { IOUtils.closeQuietly(stream); } } return ""; }
private String readFile(ServletConfig config, String path) throws ServletException { InputStream stream = config.getServletContext().getResourceAsStream(path); if (stream == null) { throw new ServletException("Cannot find file '" + path + "'!"); } try { return IOUtils.readAllLines(stream, 100000); } catch (IOException e) { throw new ServletException("Cannot read file '" + path + "': " + e.getMessage(), e); } finally { IOUtils.closeQuietly(stream); } }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String template = config.getInitParameter(PARAM_ENDPOINT_TEMPLATE); if (template == null) { LOG.error("CMIS Endpoints Document template provided!"); return; } // load template from file InputStream stream = null; try { stream = config.getServletContext().getResourceAsStream(template); if (stream != null) { endpointsDocument = IOUtils.readAllLines(stream); } } catch (Exception e) { LOG.error("Could not read CMIS Endpoints Document template from {}!", template, e); } finally { IOUtils.closeQuietly(stream); } }