jlibs.core.net
Class URLUtil

java.lang.Object
  extended by jlibs.core.net.URLUtil

public class URLUtil
extends Object

Author:
Santhosh Kumar T

Constructor Summary
URLUtil()
           
 
Method Summary
static URLConnection createUnCertifiedConnection(URL url, Proxy proxy)
          Creates connection to the specified url.
static Map<String,String> getQueryParams(String uri, String encoding)
          returns Query Parameters in specified uri as Map.
static void main(String[] args)
           
static URI relativize(String base, String child)
           
static URI resolve(String base, String child)
           
static String suggestFile(URI uri, String extension)
           
static String suggestPrefix(Properties suggested, String uri)
           
static String toSystemID(URL url)
           
static URI toURI(String str)
          Constructs URI from given string.
static URI toURI(URL url)
          Constructs URI from given URL.
static URL toURL(String systemID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLUtil

public URLUtil()
Method Detail

toURI

public static URI toURI(String str)
Constructs URI from given string. The URISyntaxException is rethrown as IllegalArgumentException


toURI

public static URI toURI(URL url)
Constructs URI from given URL. The URISyntaxException is rethrown as IllegalArgumentException


toURL

public static URL toURL(String systemID)

toSystemID

public static String toSystemID(URL url)

resolve

public static URI resolve(String base,
                          String child)

relativize

public static URI relativize(String base,
                             String child)

getQueryParams

public static Map<String,String> getQueryParams(String uri,
                                                String encoding)
                                         throws URISyntaxException,
                                                UnsupportedEncodingException
returns Query Parameters in specified uri as Map. key will be param name and value wil be param value.

Parameters:
uri - The string to be parsed into a URI
encoding - if null, UTF-8 will be used
Throws:
URISyntaxException - in case of invalid uri
UnsupportedEncodingException - if named character encoding is not supported

suggestFile

public static String suggestFile(URI uri,
                                 String extension)

suggestPrefix

public static String suggestPrefix(Properties suggested,
                                   String uri)

createUnCertifiedConnection

public static URLConnection createUnCertifiedConnection(URL url,
                                                        Proxy proxy)
                                                 throws IOException
Creates connection to the specified url. If the protocol is https the connection created doesn't validate any certificates.

Parameters:
url - url to which connection has to be created
proxy - proxy to be used. can be null
Returns:
URLConnection. the connection is not yet connected
Throws:
IOException - if an I/O exception occurs

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2018. All rights reserved.