2.15. Using Commons Codec

Problem

You want to use Commons Codec.

Solution

You must download the latest version of Jakarta Commons Codec, and place the Commons Codec JAR in your project’s classpath. Follow the steps outlined in Recipe 1.1, downloading Commons Codec 1.2 instead of Commons Lang.

Discussion

The Commons Codec library is a small library, which includes encoders and decoders for common encoding algorithms, such as Hex, Base64; and phonetic encoders, such as Metaphone, DoubleMetaphone, and Soundex. This tiny component was created to provide a definitive implementation of Base64 and Hex, encouraging reuse and reducing the amount of code duplication between various Apache projects.

If you have a Maven project that needs to use Commons Codec, add a dependency on Commons Codec 1.2 with the following section in project.xml:

<dependencies>
  <dependency>
    <id>commons-codec</id>
    <version>1.2</version>
  </dependency>

  ....other dependencies...
</dependencies>

See Also

For information on obtaining the source code for Commons Codec, see Recipe 2.16. To learn more about Commons Codec, visit the Jakarta Commons Codec web site at http://jakarta.apache.org/commons/codec/.

Get Jakarta Commons Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.