I have a simple program which tries to decode an encoded URL. But for some reason this doesn't seem to be working. Would anybody have any idea why this is happening? I have spent hours but haven't been able to figure it out.
Here is the program:
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
public class DecodeTest {
public static void main(String[] args) {
String encodedUrl = "aHR0cHM6Ly93d3cuYWUuY29tL3dlYi9teWFjY291bnQvYWNjb3VudF9ob21lLmpzcA";
String decodedUrl = "";
try {
decodedUrl = URLDecoder.decode(encodedUrl, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("String: " + decodedUrl);
}
}
The output is as follows:
String: aHR0cHM6Ly93d3cuYWUuY29tL3dlYi9teWFjY291bnQvYWNjb3VudF9ob21lLmpzcA
This is the same encoded string.