Here you can find the source of copyStream(final InputStream is, final OutputStream os)
Parameter | Description |
---|---|
is | input stream |
os | output stream |
public static boolean copyStream(final InputStream is, final OutputStream os)
//package com.java2s; //License from project: Creative Commons License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from w w w . jav a2 s .co m*/ * Copy a stream to another location * * @param is input stream * @param os output stream * @return true if successful, false otherwise */ public static boolean copyStream(final InputStream is, final OutputStream os) { try { final byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { os.write(buf, 0, len); } is.close(); os.close(); return true; } catch (final IOException e) { e.printStackTrace(); } return false; } }