Sunday 11 October 2015

Java: URLDecoder: decode strings


URLDecoder class is used to decodes strings encoded in x-www-form-url-encoded format.
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class Main {
  public static void main(String args[]) throws UnsupportedEncodingException  {
    String data = "http://www.mysite.com/?video=funny%20cat%20plays%20piano.";
    
    String result = URLDecoder.decode(data, "UTF-8");
    System.out.println(result);
    
  }
}

Output
http://www.mysite.com/?video=funny cat plays piano.


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment