Java examples for java.net:URL Encode
The following code shows how to Encode URL or input with latin characters (for HTTP GET and database)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static void main(String[] argv) { String input = "java2s.com"; System.out.println(encodeLatin1(input)); }//from w w w. j av a 2 s .co m /** * <p>Encode URL or input with latin characters (for HTTP GET and database).</p> * @param input original content or text * @return Latin1 encoded text. */ public static String encodeLatin1(final String input) { String result = null; try { result = URLEncoder.encode(input, "Latin1"); } catch (UnsupportedEncodingException e) { } catch (Exception e) { } return result; } }