Here you can find the source of copyStream(InputStream input, OutputStream output)
InputStream
into the OutputStream
.
public static void copyStream(InputStream input, OutputStream output)
//package com.java2s; /**//w w w . j a v a2 s.c o m * Copyright (c) 2005-2007 Intalio inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Intalio inc. - initial API and implementation */ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** * Copies the contents of the <code>InputStream</code> into the <code>OutputStream</code>. */ public static void copyStream(InputStream input, OutputStream output) { try { byte[] bytes = new byte[4096]; int bytesRead = 0; while ((bytesRead = input.read(bytes)) >= 0) { output.write(bytes, 0, bytesRead); } } catch (IOException e) { throw new RuntimeException(e); } } }