com.partnersoft.io.net
Class URLLib

java.lang.Object
  extended by com.partnersoft.io.net.URLLib

public class URLLib
extends java.lang.Object

Library functions involving URLs.

Author:
Paul Reavis Copyright 2004 Partner Software, Inc.

Constructor Summary
URLLib()
           
 
Method Summary
static java.net.URL createURL(java.io.File file)
           
static java.net.URL createURL(java.lang.String urlString)
          Creates a new URL.
static java.net.URL createURL(java.net.URL base, java.lang.String path)
          Creates a new URL from a base URL.
static java.lang.String decode(java.lang.String string)
           
static long download(java.net.URL source, java.io.File dest)
          Downloads a file from URL source to File destination.
static java.lang.String encode(java.lang.String string)
           
static boolean exists(java.net.URL url)
          Checks for existence of a file at the given URL.
static boolean exists(java.net.URL base, java.lang.String path)
           
static java.lang.String readLine(java.net.URL source)
           
static java.lang.String readLine(java.net.URL base, java.lang.String path)
           
static java.lang.String resolveHost(java.lang.String original)
           
static java.net.URI resolveHost(java.net.URI original)
          Resolves the given host against the Partner hosts file.
static java.net.URL resolveHost(java.net.URL original)
           
static java.lang.String resolveHostName(java.lang.String original)
          Resolves the given host against the Partner hosts file.
static long upload(java.io.File source, java.net.URL dest)
          Uploads a file from local store to a URL destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLLib

public URLLib()
Method Detail

encode

public static java.lang.String encode(java.lang.String string)

decode

public static java.lang.String decode(java.lang.String string)

createURL

public static java.net.URL createURL(java.lang.String urlString)
                              throws java.net.MalformedURLException
Creates a new URL. Takes care of space encoding etc.

Throws:
java.net.MalformedURLException

createURL

public static java.net.URL createURL(java.net.URL base,
                                     java.lang.String path)
                              throws java.net.MalformedURLException
Creates a new URL from a base URL. Takes care of space encoding etc.

Throws:
java.net.MalformedURLException

createURL

public static java.net.URL createURL(java.io.File file)
                              throws java.io.IOException
Throws:
java.io.IOException

resolveHostName

public static java.lang.String resolveHostName(java.lang.String original)
Resolves the given host against the Partner hosts file.


resolveHost

public static java.net.URI resolveHost(java.net.URI original)
Resolves the given host against the Partner hosts file.


resolveHost

public static java.net.URL resolveHost(java.net.URL original)

resolveHost

public static java.lang.String resolveHost(java.lang.String original)

download

public static long download(java.net.URL source,
                            java.io.File dest)
                     throws java.io.IOException
Downloads a file from URL source to File destination. Creates directories if needed. Returns number of bytes copied.

Throws:
java.io.IOException

upload

public static long upload(java.io.File source,
                          java.net.URL dest)
                   throws java.io.IOException
Uploads a file from local store to a URL destination. Returns number of bytes copied.

Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.net.URL source)
                                 throws java.io.IOException
Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.net.URL base,
                                        java.lang.String path)
                                 throws java.io.IOException
Throws:
java.io.IOException

exists

public static boolean exists(java.net.URL url)
                      throws java.io.IOException
Checks for existence of a file at the given URL.

Throws:
java.io.IOException

exists

public static boolean exists(java.net.URL base,
                             java.lang.String path)
                      throws java.io.IOException
Throws:
java.io.IOException