Here you can find the source of copyStreams(InputStream source, OutputStream target)
public static void copyStreams(InputStream source, OutputStream target) throws IOException
//package com.java2s; /* ----------------------------------------------------------------------------- * Antenna - An Ant-to-end solution for wireless Java * * Copyright (c) 2002-2004 Joerg Pleumann <joerg@pleumann.de> * //from w ww. j a va 2s. com * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ----------------------------------------------------------------------------- */ import java.io.*; public class Main { /** * Copies the contents of the source stream to the target stream. */ public static void copyStreams(InputStream source, OutputStream target) throws IOException { byte[] buffer = new byte[128]; int i = source.read(buffer); while (i != -1) { target.write(buffer, 0, i); i = source.read(buffer); } } }