Streams the input stream to the response.<p>

@param response the response
@param is the input stream

@throws IOException in case writing to the response fails
6864
private void streamContent(HttpServletResponse response, InputStream is) throws IOException {

        OutputStream os = response.getOutputStream();
        try {
            byte buffer[] = new byte[DEFAULT_BUFFER_SIZE];
            int bytes;
            while ((bytes = is.read(buffer)) >= 0) {
                os.write(buffer, 0, bytes);
            }
        } finally {
            os.close();
        }
    }
1026841
public static void write(HttpServletResponse response, InputStream in) {
		write(response, in, IoUtil.DEFAULT_BUFFER_SIZE);
	}
243558
public T handle(final HttpRequest request, final HttpResponse response)
        throws IOException
    {
        // Find the response stream - the error stream may be valid in cases
        // where the input stream is not.
        InputStream is = null;
        try {
            final HttpEntity httpEntity = response.getEntity();
            if (httpEntity != null) {
                is = httpEntity.getContent();
                    }
        }
        catch (IOException e) {
            log.warn("Could not locate response body stream", e);
            // normal for 401, 403 and 404 responses, for example...
        }

        if (is == null) {
            // Fall back to zero length response.
            is = new NullInputStream(0);
        }

        final Header header = response.getFirstHeader("Content-Encoding");
        if (header != null) {
            final String encoding = StringUtils.trimToEmpty(header.getValue());

            if (StringUtils.equalsIgnoreCase(encoding, "gzip") || StringUtils.equalsIgnoreCase(encoding, "x-gzip")) {
                log.debug("Found GZIP stream");
                is = new GZIPInputStream(is);
            }
            else if (StringUtils.equalsIgnoreCase(encoding, "deflate")) {
                log.debug("Found deflate stream");
                final Inflater inflater = new Inflater(true);
                is = new InflaterInputStream(is, inflater);
            }
        }
        return contentConverter.convert(request, response, is);
    }
225279
public static void write(HttpServletResponse response, InputStream in, String contentType) {
		response.setContentType(contentType);
		write(response, in);
	}
1156443
public static void write(HttpServletResponse response, File file) {
		final String fileName = file.getName();
		final String contentType = ObjectUtil.defaultIfNull(FileUtil.getMimeType(fileName), "application/octet-stream");
		BufferedInputStream in = null;
		try {
			in = FileUtil.getInputStream(file);
			write(response, in, contentType, fileName);
		} finally {
			IoUtil.close(in);
		}
	}
1308934
public void readFrom(java.io.InputStream is) throws IOException {
        int howmuch = 0;
        do {
            _write_pos += howmuch;
            moveWindow(_write_pos);
            howmuch = is.read(_memory_buffer);
        } while (howmuch != -1);
    }
653001
public void inputStreamToFile(InputStream is, String filename) throws IOException {
        FileOutputStream fos = new FileOutputStream(filename);
        inputStreamToOutputStream(is, fos);
        fos.close();
    }
369290
public void put(InputStream is) throws APIException {
        HttpResponse response = client.put(getUrl(), new InputStreamEntity(is, -1, ContentType.APPLICATION_OCTET_STREAM));
        HttpClientHelpers.throwIfNotOk(response);
    }
947730
public static void readFrom(InputStream is, int needed, ByteBuffer buffer) throws IOException {
        ByteBuffer tmp = allocate(8192);

        while (needed > 0 && buffer.hasRemaining()) {
            int l = is.read(tmp.array(), 0, 8192);
            if (l < 0)
                break;
            tmp.position(0);
            tmp.limit(l);
            buffer.put(tmp);
        }
    }
293248
public void resource(InputStream input) {
        checkCommitted();
        finalizeResponse();

        // content type to OCTET_STREAM if it's not set
        if (getContentType() == null) {
            contentType(HttpConstants.ContentType.APPLICATION_OCTET_STREAM);
        }

        try {
            send(input);
        } catch (IOException e) {
            throw new PippoRuntimeException(e);
        }
    }
509217
public static void sendStream(ObjectOutputStream oos, InputStream inputStream) throws IOException {
		int b;
		while ((b = inputStream.read()) >= 0) {
			oos.write(b);
		}
		oos.flush();
	}
1258447
public static void streamOut(OutputStream out, Object object) throws IOException {
        streamOut(out, object, false);
    }
848068
public static void copy(InputStream is, OutputStream os) throws IOException {

		Asserts.notNullParameter("is", is);
		Asserts.notNullParameter("os", os);
		
		try {
			byte[] buf = new byte[1024];
			int len = 0;
			
			while((len = is.read(buf)) > 0) {
				os.write(buf, 0, len);
			}
		
		} finally {
			if(os != null) {
				try {
					os.close();
				} catch (IOException e) {
					// ignore
				}
			}
			if(is != null) {
				try {
					is.close();
				} catch (IOException e) {
					// ignore
				}
			}
		}
	}
1225357
private void copy(InputStream is, OutputStream os) throws IOException {
		byte[] buffer = new byte[bufferSize];
		int nRead;
		while((nRead = is.read(buffer)) != -1) {
			os.write(buffer, 0, nRead);
		}
		os.flush();
	}
686681
public static void write(HttpServletResponse response, InputStream in, int bufferSize) {
		ServletOutputStream out = null;
		try {
			out = response.getOutputStream();
			IoUtil.copy(in, out, bufferSize);
		} catch (IOException e) {
			throw new UtilException(e);
		} finally {
			IoUtil.close(out);
			IoUtil.close(in);
		}
	}
25403
public static void copyStream(InputStream is, OutputStream os, int bufferSize)
            throws IOException {
        if (is == null) {
            throw MESSAGES.nullArgument("input stream");
        }
        if (os == null) {
            throw MESSAGES.nullArgument("output stream");
        }
        byte[] buff = new byte[bufferSize];
        int rc;
        while ((rc = is.read(buff)) != -1) { os.write(buff, 0, rc); }
        os.flush();
    }
76454
public static void copy(InputStream is, File file) throws IOException {

		Asserts.notNullParameter("is", is);
		Asserts.notNullParameter("file", file);
		
		FileOutputStream os = null;
		os = new FileOutputStream(file);
		copy(is, os);
	}