public void sendStream(InputStream is,long readLength) throws IOException {
  byte[] buffer=new byte[BUFFER_DEFAULT_SIZE];
  long remainingReadLength=readLength;
  int read;
  while (remainingReadLength > 0) {
    read=is.read(buffer,0,Math.min((int)remainingReadLength,BUFFER_DEFAULT_SIZE));
    if (read == -1) {
      return;
    }
    write(buffer,0,read);
    remainingReadLength-=read;
  }
}

public void sendStream ( InputStream is , long readLength ) throws IOException { byte [ ] buffer = new byte [ BUFFER_DEFAULT_SIZE ] ; long remainingReadLength = readLength ; int read ; while ( remainingReadLength > 0 ) { read = is . read ( buffer , 0 , Math . min ( ( int ) remainingReadLength , BUFFER_DEFAULT_SIZE ) ) ; if ( read == - 1 ) { return ; } write ( buffer , 0 , read ) ; remainingReadLength -= read ; } }
send stream to server .
