Example #1
0
  /**
   * decode the Hex encoded String data - whitespace will be ignored.
   *
   * @return a byte array representing the decoded data.
   */
  public static byte[] decode(String data) {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();

    try {
      encoder.decode(data, bOut);
    } catch (IOException e) {
      throw new RuntimeException("exception decoding Hex string: " + e);
    }

    return bOut.toByteArray();
  }
Example #2
0
 /**
  * decode the Hex encoded String data writing it to the given output stream, whitespace characters
  * will be ignored.
  *
  * @return the number of bytes produced.
  */
 public static int decode(String data, OutputStream out) throws IOException {
   return encoder.decode(data, out);
 }