question: private void pipe ( InputStream in , OutputStream out ) throws IOException { BufferedOutputStream bufferedOut = new BufferedOutputStream ( out ) ; int n ; byte [ ] bytes = new byte [ 1024 * 4 ] ; while ( ( n = in . read ( bytes ) ) != - 1 ) { bufferedOut . write ( bytes , 0 , n ) ; } bufferedOut . flush ( ) ; bufferedOut . close ( ) ; in . close ( ) ; }
target:  Reads all the data from the specified input stream and writes it to the specified output stream. Both streams are also closed.