public static void toFile ( InputStream input , File file ) throws IOException { OutputStream os = new FileOutputStream ( file ) ; int bytesRead = 0 ; byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; while ( ( bytesRead = input . read ( buffer , 0 , DEFAULT_BUFFER_SIZE ) ) != - 1 ) { os . write ( buffer , 0 , bytesRead ) ; } IOUtils . closeQuietly ( os ) ; IOUtils . closeQuietly ( input ) ; }
InputStream to File