public static Properties getResourceAsProperties(final String resource) { final InputStream is = getResourceAsStream(resource); if (is == null) { return null; } final Properties props = new Properties(); try { props.load(is); } catch (final IOException ex) { throw new RuntimeException(ex); } finally { try { is.close(); } catch (final IOException ignore) { // ignore } } return props; }
public static Properties getResourceAsProperties(final String resource) { final InputStream is = getResourceAsStream(resource); if (is == null) { return null; } final Properties props = new Properties(); try { props.load(is); } catch (final IOException ex) { throw new RuntimeException(ex); } finally { try { is.close(); } catch (final IOException ignore) { // ignore } } return props; }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String servletPath = stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); } }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }