Code example for URI

Methods: toURL

0
 
    private static final int TIMEOUT_MS = 20000;
 
    public static String encodeUrl(String urlString) throws MalformedURLException, URISyntaxException {
        URL url = new URL(urlString);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
        url = uri.toURL();
        return url.toString();
    } 
 
    public static HttpClient getDefaultClient() {
        HttpParams httpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MS);      
        HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MS);  
 
        String userAgentString = new StringBuilder().
                append("WSAndroid 1.3.2").append(" ")
                .append(Build.MANUFACTURER).append(" ")
                .append(Build.MODEL).append(" ")
                .append("Android v").append(Build.VERSION.RELEASE)
                .toString();