public static long copy(
                    final InputStream input,
                    final File output
                    )
    throws IOException
    {
        OutputStream  stream_output = null;
        long  size = 0L;
        try {
            stream_output = new FileOutputStream( output );
                            //throws FileNotFoundException
            size = copy( input, stream_output );
                   //throws IOException
        } finally {
            try {
                stream_output.close();
            } catch (Exception ex) {
                //ignorable
            }
        }

        return size;

    }
public static long copy ( final InputStream input , final File output ) throws IOException { OutputStream stream_output = null ; long size = 0L ; try { stream_output = new FileOutputStream ( output ) ; size = copy ( input , stream_output ) ; } finally { try { stream_output . close ( ) ; } catch ( Exception ex ) { } } return size ; }
Reads the contents from the specified stream and writes them to the file.

@param   input
the input stream.
@param   output
the output file.
@return
the total number of bytes written to the output.