private static void streamCopy ( InputStream is , OutputStream os , byte [ ] buf , boolean close ) throws IOException { int len ; if ( buf == null ) { buf = new byte [ 4096 ] ; } while ( ( len = is . read ( buf ) ) > 0 ) { os . write ( buf , 0 , len ) ; } os . flush ( ) ; if ( close ) { is . close ( ) ; } }
Copy the contents of is to os .