public int decode(byte[] data,int off,int length,OutputStream out) throws IOException {
  byte b1, b2;
  int outLen=0;
  int end=off + length;
  while (end > off) {
    if (!ignore((char)data[end - 1])) {
      break;
    }
    end--;
  }
  int i=off;
  while (i < end) {
    while (i < end && ignore((char)data[i])) {
      i++;
    }
    b1=decodingTable[data[i++]];
    while (i < end && ignore((char)data[i])) {
      i++;
    }
    b2=decodingTable[data[i++]];
    if ((b1 | b2) < 0) {
      throw new IOException("invalid characters encountered in Hex data");
    }
    out.write((b1 << 4) | b2);
    outLen++;
  }
  return outLen;
}

public int decode ( byte [ ] data , int off , int length , OutputStream out ) throws IOException { byte b1 , b2 ; int outLen = 0 ; int end = off + length ; while ( end > off ) { if ( ! ignore ( ( char ) data [ end - 1 ] ) ) { break ; } end -- ; } int i = off ; while ( i < end ) { while ( i < end && ignore ( ( char ) data [ i ] ) ) { i ++ ; } b1 = decodingTable [ data [ i ++ ] ] ; while ( i < end && ignore ( ( char ) data [ i ] ) ) { i ++ ; } b2 = decodingTable [ data [ i ++ ] ] ; if ( ( b1 | b2 ) < 0 ) { throw new IOException ( "invalid characters encountered in Hex data" ) ; } out . write ( ( b1 << 4 ) | b2 ) ; outLen ++ ; } return outLen ; }
decode the hex encoded byte data writing it to the given output stream , whitespace characters will be ignored .
