Common Java Cookbook

Edition: 0.19

Download PDF or Read on Scribd

Download Examples (ZIP)

2.15. Using Commons Codec

2.15.1. Problem

You want to use Commons Codec.

2.15.2. Solution

To use Commons Codec in a Maven 2 project, add the following dependency to your project's pom.xml:

Example 2.1. Adding a Dependency on Commons Codec

<dependency>
  <groupId>commons-codec</groupId>
  <artifactId>commons-codec</artifactId>
  <version>1.3</version>
</dependency>  

If you are not sure what this means, I'd suggest reading Maven: The Definitive Guide. When you depend on a library in Maven 2, all you need to do is add the dependency groupId, artifactId, and version to your project's dependencies. Once you do this, Maven 2 will download the dependency and make it available on your project's classpath.

2.15.3. 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.

2.15.4. See Also

To learn more about Commons Codec, visit the Commons Codec project at http://commons.apache.org/codec/.


Creative Commons License
Common Java Cookbook by Tim O'Brien is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.discursive.com/books/cjcook/reference/jakartackbk-PREFACE-1.html. Copyright 2009. Common Java Cookbook Chunked HTML Output. Some Rights Reserved.