net.spy.util
Class SpyUtil

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

public class SpyUtil
extends Object

Miscellaneous utilities.


Method Summary
static String byteAToHexString(byte[] me)
          Get a string representing the hexidecimal value of the given byte array.
static String deHTML(String contents)
          Remove HTML tags from a string.
static Boolean getBoolean(String s)
          Returns a Boolean with a value represented by the specified String.
static String getFileData(File file)
          Return the contents of a file as a string.
static String getReaderAsString(Reader r)
          Load the contents of the given reader as a String.
static String join(Collection<?> c, String on)
          Join a Collection of Objects on a join string.
static
<T> String
join(Enumeration<T> e, String on)
          Join an Enumeration of Strings on a join string.
static String join(Iterator<?> i, String on)
          Join an Iterator of Objects on a join string.
static void rmDashR(File tmp)
          Recursively remove a path.
static void runClass(ClassLoader cl, String classname, String[] args)
          Class invoker (runs main(String[]) from a String array.
static void runClass(String classname, String[] args)
          Class invoker (runs main(String[]) from a String array.
static Object[] shuffle(Object[] in)
          Shuffle (unsort) an array.
static String[] split(String on, 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 Object[] shuffle(Object[] in)
Shuffle (unsort) an array.

Parameters:
in - The array of objects to shuffle.

split

public static String[] split(String on,
                             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 String getReaderAsString(Reader r)
                                throws 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:
IOException

getFileData

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

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

join

public static <T> String join(Enumeration<T> e,
                              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 String join(Iterator<?> i,
                          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 String join(Collection<?> c,
                          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 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(String classname,
                            String[] args)
                     throws Exception
Class invoker (runs main(String[]) from a String array.

Throws:
Exception

runClass

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

Throws:
Exception

getBoolean

public static Boolean getBoolean(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

deHTML

public static String deHTML(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(File tmp)
Recursively remove a path.



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