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 info R rishabh Mahrsee 1 Improve Article Tags : Java Explore Java BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java5 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java7 min readOOP & InterfacesClasses and Objects in Java10 min readAccess Modifiers in Java5 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking15+ min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like