Here you can find the source of inputStreamToOutputStream(InputStream is, OutputStream os)
Parameter | Description |
---|---|
is | the input stream to read |
Parameter | Description |
---|---|
IOException | an exception |
public static void inputStreamToOutputStream(InputStream is, OutputStream os) throws IOException
//package com.java2s; /*/* w w w . j a v a2 s . co m*/ * Copyright (C) 2010 - 2012 Jenia Software. * * This file is part of Sinekarta * * Sinekarta is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Sinekarta 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 General Public License for more details. * */ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** * copy of an inputstream to corresponding outputStream * be carefull on using this method * * @param is the input stream to read * @throws IOException */ public static void inputStreamToOutputStream(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[8192]; int len = is.read(buf); while (len >= 0) { os.write(buf, 0, len); os.flush(); len = is.read(buf); } is.close(); os.flush(); os.close(); } }