Class CombinedURL

java.lang.Object
de.stefanfrings.utils.CombinedURL

public class CombinedURL extends Object
Extended version of the URL class, supports proxy and authentication, can send HTTP header and post parameters.

Examples:

  • http://stefan:password@www.whatever.com/private/music.mp3
  • ftp://stefan:password@ftp.whatever.com/private/music.mp3
  • http://freeproxy:8080?http://www.google.com/search?q=linux
  • http://freeproxy:8080?http://stefan:password@www.whatever.com/private/music.mp3
  • http://stefan:password@wwwproxy:8080?http://stefan:password@www.whatever.com/private/music.mp3

The syntax of a combined URL is:

  • [proxy?]server

The syntax of the optional proxy part is:

  • http://[username:password@]host:port
  • socks://[username:password@]host:port

The syntax of server part is:

  • http://[username:password@]host[:port]/[path/][filename][?parameters]
  • ftp://[username:password@]host[:port]/[path/]filename
  • file:///[path/]filename   (reative to current working directory)
  • file:////[path/]filename   (Unix absolute path)
  • file://drive:/[path/]filename   (Windows absolute path)
  • file://server/[path/]filename   (Windows absolute path)

Other protocols might work but have not been tested.

Author:
Stefan Frings, http://stefanfrings.de/javautils
  • Constructor Details

    • CombinedURL

      public CombinedURL(URL proxyURL, URL serverURL) throws MalformedURLException
      Constructor that takes proxy and server URL.
      Parameters:
      proxyURL - proxy settings
      serverURL - server settings
      Throws:
      MalformedURLException - If the URL is invalid.
    • CombinedURL

      public CombinedURL(String proxy, String server) throws MalformedURLException
      Constructor that takes proxy and server URL as string.
      Parameters:
      proxy - proxy settings
      server - server settings
      Throws:
      MalformedURLException - If the URL is invalid.
    • CombinedURL

      public CombinedURL(String combined) throws MalformedURLException
      Constructor that takes a server URL or combined URL as string.

      This constructor detect automatically whether the argument contains the optional proxy URL followed by "?" followed by the mandatory server URL.

      Parameters:
      combined - Combined string with optional proxy URL and server URL
      Throws:
      MalformedURLException - If the URL is invalid.
  • Method Details