private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/css; charset=UTF-8"); URL url = this.getClass().getResource("servicelist.css"); if (url != null) { IOUtils.copy(url.openStream(), response.getOutputStream()); } }
protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { InputStream is = super.getServletContext().getResourceAsStream(pathInfo); if (is == null) { throw new ServletException("Static resource " + pathInfo + " is not available"); } try { int ind = pathInfo.lastIndexOf("."); if (ind != -1 && ind < pathInfo.length()) { String type = STATIC_CONTENT_TYPES.get(pathInfo.substring(ind + 1)); if (type != null) { response.setContentType(type); } } ServletOutputStream os = response.getOutputStream(); IOUtils.copy(is, os); os.flush(); } catch (IOException ex) { throw new ServletException("Static resource " + pathInfo + " can not be written to the output stream"); } }
if (src.getInputStream() != null) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream(2048)) { IOUtils.copy(src.getInputStream(), bos, 1024); ds = new ByteDataSource(bos.toByteArray(), ct);
try { InputStream in = ds.getInputStream(); IOUtils.copy(in, out); in.close(); out.flush();
public static void copyAndCloseInput(final Reader input, final Writer output) throws IOException { try { copy(input, output, DEFAULT_BUFFER_SIZE); } finally { input.close(); } }
public static void copyAndCloseInput(final Reader input, final Writer output, int bufferSize) throws IOException { try { copy(input, output, bufferSize); } finally { input.close(); } }
public static int copyAndCloseInput(final InputStream input, final OutputStream output) throws IOException { try { return copy(input, output); } finally { input.close(); } }
public static void copyAndCloseInput(final Reader input, final Writer output, int bufferSize) throws IOException { try { copy(input, output, bufferSize); } finally { input.close(); } }
public static byte[] readBytesFromStream(InputStream in) throws IOException { int i = in.available(); if (i < DEFAULT_BUFFER_SIZE) { i = DEFAULT_BUFFER_SIZE; } try (ByteArrayOutputStream bos = new ByteArrayOutputStream(i)) { copy(in, bos); return bos.toByteArray(); } finally { in.close(); } } }
private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/css; charset=UTF-8"); URL url = this.getClass().getResource("servicelist.css"); if (url != null) { IOUtils.copy(url.openStream(), response.getOutputStream()); } }
private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/css; charset=UTF-8"); URL url = this.getClass().getResource("servicelist.css"); if (url != null) { IOUtils.copy(url.openStream(), response.getOutputStream()); } }
public static String readBody(InputStream is, String encoding) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(is, bos, 1024); return new String(bos.toByteArray(), encoding); } catch (Exception ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } }
if (in != null) { CachedOutputStream cos = new CachedOutputStream(); IOUtils.copy(in, cos); inMessage.setContent(InputStream.class, cos.getInputStream());
protected void writeJws(JwsJsonProducer p, OutputStream os) throws IOException { byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument()); IOUtils.copy(new ByteArrayInputStream(bytes), os); }
protected void writeJws(JwsJsonProducer p, OutputStream os) throws IOException { byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument()); IOUtils.copy(new ByteArrayInputStream(bytes), os); }
@Override public int copyFrom(InputStream in) throws IOException { if (written) { return IOUtils.copy(in, out); } CountingInputStream c = new CountingInputStream(in); if (!sendContent(InputStream.class, c) && !sendContent(Object.class, c)) { IOUtils.copy(c, out); } return c.getCount(); } public void write(int b) throws IOException {
public void onMessage(Message message) { LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream(); try { IOUtils.copy(message.getContent(InputStream.class), bout); message.getExchange().put(InputStream.class, bout.createInputStream()); c.close(message); } catch (IOException e) { //ignore } } });