Bug in Apache Commons Codec 1.4

If you get the java.lang.IllegalArgumentException: Illegal character(s) in message header value: message, you need to upgrade to 1.5.

https://issues.apache.org/jira/browse/CODEC-89

Advertisements

How to Encode/Decode to Base64 with Apache Commons Codec

import static java.lang.System.out;
import static org.apache.commons.codec.binary.Base64.encodeBase64;

public final class CommonsCodecSample {

  public static void main(final String[] args) {
    out.println(encodeBase64("Simples Assim".getBytes()); // decodeBase64 for decoding
  }

}

How to Encode/Decode to Hexadecimal with Apache Commons Codec

import static java.lang.System.out;
import static org.apache.commons.codec.binary.Hex.encodeHex;

public final class CommonsCodecSample {

  public static void main(final String[] args) {
    out.println(encodeHex("Simples Assim".getBytes())); // decodeHex for decoding
  }

}