Java.net.URLDecoder class in Java Last Updated : 16 Jun, 2017 Comments Improve Suggest changes Like Article Like Report This is a utility class for HTML form decoding. It just performs the reverse of what URLEncoder class do, i.e. given an encoded string, it decodes it using the scheme specified. Generally when accessing the contents of request using getParameter() method in servlet programming, the values are automatically decoded before they are returned. But sometimes there may be a need to explicitly decode an otherwise URL encoded string. The following steps are followed while decoding the strings: Alphanumeric characters and certain special characters such as '*', '_', '-' and '.' remains unchanged. '+' signs are converted into spaces. All other characters are decoded using the encoding scheme specified. The string of the form %xy, is converted to the character whose encoding would have resulted in this three character representation. W3C recommends using "UTF-8" for encoding purposes. For example, the encoded string u%40geeks+for+geeks will be converted into the string representation where %40 will be replaced by an @ symbol and + signs are converted into space characters. u@geeks for geeks Methods : decode() : This is one and only method provided by this class. It as the name suggests returns an decoded string for the specified string. One method, which is now deprecated has only one parameter, the string to be decoded. It doesn't let you specify the encoding scheme used and uses the platform default encoding scheme. Another version allows the specification of the encoding to be used, and thus is widely used. Syntax :public static String decode(String s)- @Deprecated Parameters : s : encoded string to be decoded Syntax :public static String decode(String s, String enc) throws UnsupportedEncodingException Parameters : s : string to be decoded enc : encoding to be used Throws : UnsupportedEncodingException : If the specified encoding is not used Java Implementation : Java // Java program to show decode() method of // URLDecoder class import java.io.UnsupportedEncodingException; import java.net.URLDecoder; public class urlDecoder { public static void main(String[] args) throws UnsupportedEncodingException { // encoded string String encodedString = "u%40geeks+for+geeks"; System.out.println("Encoded String :"); System.out.println(encodedString); // decode() method System.out.println("Decoded String :"); System.out.println(URLDecoder.decode(encodedString, "UTF-8")); } } Output : Encoded String : u%40geeks+for+geeks Decoded String : u@geeks for geeks References : Official Java Documentation Comment More infoAdvertise with us Next Article Java.net.URLDecoder class in Java R Rishabh Mahrsee Improve Article Tags : Java Practice Tags : Java Similar Reads Java.net.URLEncoder class in Java This class is a utility class for HTML form encoding. Encoding makes the form of URL more reliable and secure. When the user request is triggered by a get method, the form parameters and their values are appended at the end of URL after a '?' sign. The problem arises when special characters are used 3 min read java.net.URL Class in Java URL is an acronym of Uniform resource locator. It is a pointer to locate resource in www (World Wide Web). A resource can be anything from a simple text file to any other like images, file directory etc. The typical URL may look like http://www.example.com:80/index.htmlThe URL has the following part 4 min read java.net.URLConnection Class in Java URLConnection Class in Java is an abstract class that represents a connection of a resource as specified by the corresponding URL. It is imported by the java.net package. The URLConnection class is utilized for serving two different yet related purposes, Firstly it provides control on interaction wi 5 min read Java.Lang.Byte class in Java In Java, Byte class is a wrapper class for the primitive type byte which contains several methods to effectively deal with a byte value like converting it to a string representation, and vice-versa. An object of the Byte class can hold a single byte value. Constructors of Byte Class There are mainly 6 min read java.net.CacheRequest Class in Java CacheRequest class is used in java whenever there is a need for, storage of resources in ResponseCache. More precisely instances of this class provide an advantage for the OutputStream object to store resource data into the cache, in fact, This OutputStream object is invoked by protocol handlers. Ca 3 min read Like