Java Encode and Decode URL Query String using Apache Commons Codec In this Java tutorial we learn how to encode a String to URL safe form and decode the URL safe string to original form using the URLCodec class of Apache Commons Codec library.