Here you can find the source of copyStream(final InputStream in, final OutputStream out)
Parameter | Description |
---|---|
in | the input stream to be copied |
out | the output stream to which the copy is done |
Parameter | Description |
---|---|
IOException | if a I/O problem occurs |
public static void copyStream(final InputStream in, final OutputStream out) throws IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from w w w . j av a2s . c om*/ * Copies the contents of a stream to another. * * @param in * the input stream to be copied * @param out * the output stream to which the copy is done * @throws IOException * if a I/O problem occurs */ public static void copyStream(final InputStream in, final OutputStream out) throws IOException { int bytesRead; byte[] b = new byte[10000]; while ((bytesRead = in.read(b)) != -1) { out.write(b, 0, bytesRead); } out.flush(); } }