private static void copyStreamWithoutClosing ( InputStream in , OutputStream out ) throws IOException { final int bufferSize = 4096 ; byte [ ] b = new byte [ bufferSize ] ; int n ; while ( ( n = in . read ( b ) ) != - 1 ) { out . write ( b , 0 , n ) ; } }
Copies an input stream into an output stream but does not close the streams .