List of usage examples for javax.imageio.stream ImageOutputStream length
long length() throws IOException;
From source file:org.mrgeo.services.ServletUtils.java
/** * Writes an image to a servlet response * @param response servlet response/*w w w .ja v a 2 s.c o m*/ * @param image image bytes * @throws IOException */ public static void writeImageToResponse(HttpServletResponse response, byte[] image) throws IOException { try { ImageOutputStream imageStream = new MemoryCacheImageOutputStream(response.getOutputStream()); imageStream.write(image, 0, image.length); response.setContentLength((int) imageStream.length()); imageStream.close(); } // TODO: remove these catches - This is to prevent seeing the broken pipes exception // over and over again in the trace...leave catch in until issue is fixed (#1122) catch (IIOException e) { } catch (IndexOutOfBoundsException e) { } }