public static int copyStreamCount(final InputStream in, final OutputStream out) throws IOException {
        final byte[] buffer = new byte[10240];
        int tot=0;
        int c;
        c = in.read(buffer);
        while (c >= 0) {
            if (c > 0) {
                out.write(buffer, 0, c);
                tot += c;
            }
            c = in.read(buffer);
        }
        return tot;
    }
public static int copyStreamCount ( final InputStream in , final OutputStream out ) throws IOException { final byte [ ] buffer = new byte [ 10240 ] ; int tot = 0 ; int c ; c = in . read ( buffer ) ; while ( c >= 0 ) { if ( c > 0 ) { out . write ( buffer , 0 , c ) ; tot += c ; } c = in . read ( buffer ) ; } return tot ; }
Read the data from the input stream and copy to the outputstream.

@param in  inputstream
@param out outpustream
@return number of bytes copied

@throws java.io.IOException if thrown by underlying io operations