jsky.util
Class FileUtil

java.lang.Object
  extended by jsky.util.FileUtil

public class FileUtil
extends java.lang.Object

Contains static utility methods for dealing with files and URLs.


Constructor Summary
FileUtil()
           
 
Method Summary
static void copy(java.io.InputStream in, java.io.OutputStream out)
          Copy the given input stream to the given output stream.
static java.lang.String getContents(java.io.File file)
          Return the contents of the given file as a String
static java.lang.String getURL(java.net.URL url)
          Return the contents of the URL as a String
static void main(java.lang.String[] args)
          test main
static java.net.URL makeURL(java.net.URL context, java.lang.String fileOrUrlStr)
          Given a URL context (for resolving relative path names) and a string, which may be either a file or a URL string, return a new URL made from the string.
static java.io.InputStream makeURLStream(java.net.URL url)
          This method returns an InputStream for the given URL, and also wraps it in a BufferedInputStream, if necessary.
static java.io.InputStream makeURLStream(java.net.URL context, java.lang.String fileOrUrlStr)
          Given a URL context (for resolving relative path names) and a string, which may be either a file or a URL string, return a new InputStream by creating the URL and opening it for reading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

makeURL

public static java.net.URL makeURL(java.net.URL context,
                                   java.lang.String fileOrUrlStr)
Given a URL context (for resolving relative path names) and a string, which may be either a file or a URL string, return a new URL made from the string.

Parameters:
context - the base URL, used to resolve relative path names (may be null)
fileOrUrlStr - a file name or URL string (may be relative)

makeURLStream

public static java.io.InputStream makeURLStream(java.net.URL url)
This method returns an InputStream for the given URL, and also wraps it in a BufferedInputStream, if necessary.

Parameters:
url - the URL to read

makeURLStream

public static java.io.InputStream makeURLStream(java.net.URL context,
                                                java.lang.String fileOrUrlStr)
Given a URL context (for resolving relative path names) and a string, which may be either a file or a URL string, return a new InputStream by creating the URL and opening it for reading.

Parameters:
context - the base URL, used to resolve relative path names
fileOrUrlStr - a file name or URL string (may be relative)

copy

public static void copy(java.io.InputStream in,
                        java.io.OutputStream out)
                 throws java.io.IOException
Copy the given input stream to the given output stream.

Throws:
java.io.IOException

getURL

public static java.lang.String getURL(java.net.URL url)
                               throws java.io.IOException
Return the contents of the URL as a String

Throws:
java.io.IOException

getContents

public static java.lang.String getContents(java.io.File file)
                                    throws java.io.IOException
Return the contents of the given file as a String

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
test main