net.spy.util
Class SpyUtil

java.lang.Object
  extended by net.spy.util.SpyUtil

public class SpyUtil
extends java.lang.Object

Miscellaneous utilities.


Method Summary
static java.lang.String byteAToHexString(byte[] me)
          Get a string representing the hexidecimal value of the given byte array.
static java.lang.String deHTML(java.lang.String contents)
          Remove HTML tags from a string.
static java.lang.Boolean getBoolean(boolean b)
          Get a boolean instance.
static java.lang.Boolean getBoolean(java.lang.String s)
          Returns a Boolean with a value represented by the specified String.
static java.lang.String getFileData(java.io.File file)
          Return the contents of a file as a string.
static java.lang.String getReaderAsString(java.io.Reader r)
          Load the contents of the given reader as a String.
static java.lang.String join(java.util.Collection c, java.lang.String on)
          Join a Collection of Objects on a join string.
static java.lang.String join(java.util.Enumeration e, java.lang.String on)
          Join an Enumeration of Strings on a join string.
static java.lang.String join(java.util.Iterator i, java.lang.String on)
          Join an Iterator of Objects on a join string.
static void rmDashR(java.io.File tmp)
          Recursively remove a path.
static void runClass(java.lang.ClassLoader cl, java.lang.String classname, java.lang.String[] args)
          Class invoker (runs main(String[]) from a String array.
static void runClass(java.lang.String classname, java.lang.String[] args)
          Class invoker (runs main(String[]) from a String array.
static java.lang.Object[] shuffle(java.lang.Object[] in)
          Shuffle (unsort) an array.
static java.lang.String[] split(java.lang.String on, java.lang.String input)
          Split a string based on a tokenizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

shuffle

public static java.lang.Object[] shuffle(java.lang.Object[] in)
Shuffle (unsort) an array.

Parameters:
in - The array of objects to shuffle.

split

public static java.lang.String[] split(java.lang.String on,
                                       java.lang.String input)
Split a string based on a tokenizer.

Parameters:
on - the string to split on (from StringTokenizer)
input - the string that needs to be split
See Also:
StringTokenizer

getReaderAsString

public static java.lang.String getReaderAsString(java.io.Reader r)
                                          throws java.io.IOException
Load the contents of the given reader as a String.

Parameters:
r - a reader
Returns:
a String with the contents of the reader
Throws:
java.io.IOException

getFileData

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

Parameters:
file - File to read.
Throws:
java.io.IOException - Thrown if the file cannot be opened.

join

public static java.lang.String join(java.util.Enumeration e,
                                    java.lang.String on)
Join an Enumeration of Strings on a join string.

Parameters:
e - The enumeration
on - the join string
Returns:
a new String with all of the elements joined

join

public static java.lang.String join(java.util.Iterator i,
                                    java.lang.String on)
Join an Iterator of Objects on a join string. Each object's toString() method will be used for stringification.

Parameters:
i - the iterator of Objects
on - the join string
Returns:
a new String with all of the elements joined

join

public static java.lang.String join(java.util.Collection c,
                                    java.lang.String on)
Join a Collection of Objects on a join string. Each object's toString() method will be used for stringification.

Parameters:
c - the collection
on - the join string
Returns:
a String with all the elements joined

byteAToHexString

public static java.lang.String byteAToHexString(byte[] me)
Get a string representing the hexidecimal value of the given byte array.

Parameters:
me - the byte array that needs hexified.

runClass

public static void runClass(java.lang.String classname,
                            java.lang.String[] args)
                     throws java.lang.Exception
Class invoker (runs main(String[]) from a String array.

Throws:
java.lang.Exception

runClass

public static void runClass(java.lang.ClassLoader cl,
                            java.lang.String classname,
                            java.lang.String[] args)
                     throws java.lang.Exception
Class invoker (runs main(String[]) from a String array.

Throws:
java.lang.Exception

getBoolean

public static java.lang.Boolean getBoolean(java.lang.String s)
Returns a Boolean with a value represented by the specified String. The Boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".

Parameters:
s - the string
Returns:
the Boolean instance

getBoolean

public static java.lang.Boolean getBoolean(boolean b)
Get a boolean instance.

Parameters:
b - the type of Boolean instance you want
Returns:
a shared instance of Boolean

deHTML

public static java.lang.String deHTML(java.lang.String contents)
Remove HTML tags from a string.

Parameters:
contents - the string whose HTML tags need removed.
Returns:
the deHTMLed string

rmDashR

public static void rmDashR(java.io.File tmp)
Recursively remove a path.



Copyright © 1995-2005 SPY Internetworking. All Rights Reserved.