private static void unpackFile ( InputStream in , File file ) { byte [ ] buffer = new byte [ 4096 ] ; try { OutputStream out = new FileOutputStream ( file ) ; int read ; while ( ( read = in . read ( buffer ) ) != - 1 ) { out . write ( buffer , 0 , read ) ; } out . close ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Write the contents of an InputStream to a file