net.sf.provisioner.utils
Class PathHelper

java.lang.Object
  extended by net.sf.provisioner.utils.PathHelper

public class PathHelper
extends java.lang.Object

Helper class for loading files. Makes an attempt at interpreting String paths into URLs, local jars, local files, or ClassLoader resources.

Version:
$Revision: 1.1.2.1 $
Author:
Gordon Pearson

Constructor Summary
PathHelper()
           
 
Method Summary
static java.io.InputStream pathToStream(java.lang.String path)
          Attempts to convert a path to an InputStream.
static java.net.URL pathToURL(java.lang.String path)
          Attempts to convert a path to a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathHelper

public PathHelper()
Method Detail

pathToStream

public static java.io.InputStream pathToStream(java.lang.String path)
                                        throws java.io.IOException,
                                               java.net.MalformedURLException
Attempts to convert a path to an InputStream. In order, attempts to:

Parameters:
path - a URI, local filesystem reference, or resource reference.
Returns:
an InputStream to path's content, or null if the path doesn't point to something.
Throws:
java.io.IOException
java.net.MalformedURLException - if the path contains a protocol, but is not a valid URL.

pathToURL

public static java.net.URL pathToURL(java.lang.String path)
                              throws java.io.IOException,
                                     java.net.MalformedURLException
Attempts to convert a path to a URL. In order, checks if :

Parameters:
path - a URL string, local filesystem reference, or resource reference.
Returns:
a URL or null if the path cannot be converted.
Throws:
java.io.IOException
java.net.MalformedURLException - if the path contains a protocol, but is not a valid URL.


Copyright © 2007-2008. All Rights Reserved.