@Override public byte[] decode(final byte[] data) throws IOException {
  String line;
  StringBuilder value=new StringBuilder();
  final StringBuilder valuesRead=new StringBuilder();
  BufferedReader mappingStream=null;
  ByteArrayInputStream bis=null;
  try {
    bis=new ByteArrayInputStream(data);
    mappingStream=new BufferedReader(new InputStreamReader(bis));
    if (mappingStream != null) {
      while (true) {
        line=mappingStream.readLine();
        if (line == null) {
          break;
        }
        valuesRead.append(line);
      }
    }
  }
 catch (  final Exception e) {
    LogWriter.writeLog("Exception " + e + " reading ASCII stream ");
  }
  if (mappingStream != null) {
    try {
      mappingStream.close();
      bis.close();
    }
 catch (    final IOException e) {
      LogWriter.writeLog("Exception: " + e.getMessage());
    }
  }
  final int data_size=valuesRead.length();
  int i=0, count=0;
  char current;
  final FastByteArrayOutputStream bos=new FastByteArrayOutputStream(data.length);
  while (true) {
    current=valuesRead.charAt(i);
    if ((current >= '0' && current <= '9') || (current >= 'a' && current <= 'f') || (current >= 'A' && current <= 'F')) {
      value.append(current);
      if (count == 1) {
        bos.write(Integer.valueOf(value.toString(),16));
        count=0;
        value=new StringBuilder();
      }
 else {
        count++;
      }
    }
    if (current == '>') {
      break;
    }
    i++;
    if (i == data_size) {
      break;
    }
  }
  if (count == 1) {
    value.append('0');
    bos.write(Integer.valueOf(value.toString(),16));
  }
  return bos.toByteArray();
}

@ Override public byte [ ] decode ( final byte [ ] data ) throws IOException { String line ; StringBuilder value = new StringBuilder ( ) ; final StringBuilder valuesRead = new StringBuilder ( ) ; BufferedReader mappingStream = null ; ByteArrayInputStream bis = null ; try { bis = new ByteArrayInputStream ( data ) ; mappingStream = new BufferedReader ( new InputStreamReader ( bis ) ) ; if ( mappingStream != null ) { while ( true ) { line = mappingStream . readLine ( ) ; if ( line == null ) { break ; } valuesRead . append ( line ) ; } } } catch ( final Exception e ) { LogWriter . writeLog ( "Exception " + e + " reading ASCII stream " ) ; } if ( mappingStream != null ) { try { mappingStream . close ( ) ; bis . close ( ) ; } catch ( final IOException e ) { LogWriter . writeLog ( "Exception: " + e . getMessage ( ) ) ; } } final int data_size = valuesRead . length ( ) ; int i = 0 , count = 0 ; char current ; final FastByteArrayOutputStream bos = new FastByteArrayOutputStream ( data . length ) ; while ( true ) { current = valuesRead . charAt ( i ) ; if ( ( current >= '0' && current <= '9' ) || ( current >= 'a' && current <= 'f' ) || ( current >= 'A' && current <= 'F' ) ) { value . append ( current ) ; if ( count == 1 ) { bos . write ( Integer . valueOf ( value . toString ( ) , 16 ) ) ; count = 0 ; value = new StringBuilder ( ) ; } else { count ++ ; } } if ( current == '>' ) { break ; } i ++ ; if ( i == data_size ) { break ; } } if ( count == 1 ) { value . append ( '0' ) ; bos . write ( Integer . valueOf ( value . toString ( ) , 16 ) ) ; } return bos . toByteArray ( ) ; }
asciihexdecode using our own implementation
