org.openspml.util
Class Util

java.lang.Object
  |
  +--org.openspml.util.Util

public class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static java.util.List decodeCommaString(java.lang.String src)
           
static java.util.List decodeCommaString(java.lang.String src, boolean filterEmpty)
           
static java.util.List decodeNewlineString(java.lang.String data, boolean filterEmpty)
          Given a newline deliminted string, break it up into a List of Strings.
static java.lang.String encodeCommaString(java.util.List list)
          Convert a list of strings into a comma delimited list.
static java.lang.String encodeCommaString(java.util.List list, boolean filterEmpty)
           
static java.lang.String findFile(java.lang.String name)
           
static java.lang.String findFile(java.lang.String property, java.lang.String name)
           
static java.lang.String findOutputFile(java.lang.String name)
          Build an absolute path name for a file.
static boolean isAbsolutePath(java.lang.String path)
           
static java.lang.String readFile(java.lang.String name)
          Read the contents of a file and return it as a String.
static byte[] readFileBytes(java.io.File file)
          Read the contents of a file and return it as a String.
static void writeFile(java.lang.String name, java.lang.String contents)
          Store the contents of a String in a file.
static void writeFileQuietly(java.lang.String name, java.lang.String contents)
          Store the contents of a String in a file, ignoring exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

writeFile

public static void writeFile(java.lang.String name,
                             java.lang.String contents)
                      throws java.io.IOException
Store the contents of a String in a file.

writeFileQuietly

public static void writeFileQuietly(java.lang.String name,
                                    java.lang.String contents)
Store the contents of a String in a file, ignoring exceptions.

findOutputFile

public static java.lang.String findOutputFile(java.lang.String name)
Build an absolute path name for a file. Typically used when you want to write an output file to the "current working directory". If the name is already an absolute path we use it, otherwise we use the system property "user.dir" as the root directory and add the name.

readFileBytes

public static byte[] readFileBytes(java.io.File file)
                            throws java.io.IOException
Read the contents of a file and return it as a String.

readFile

public static java.lang.String readFile(java.lang.String name)
                                 throws java.io.IOException
Read the contents of a file and return it as a String.

isAbsolutePath

public static boolean isAbsolutePath(java.lang.String path)
Returns:
true if the specified path appears to be an absolute path; otherwise false.

Don't bother to call this if you already have (or plan to construct) a File with the specified path. This method is a poor man's File.isAbsolute(), this method's advantage is that it avoids object construction.


findFile

public static java.lang.String findFile(java.lang.String property,
                                        java.lang.String name)

findFile

public static java.lang.String findFile(java.lang.String name)

decodeCommaString

public static java.util.List decodeCommaString(java.lang.String src)

decodeCommaString

public static java.util.List decodeCommaString(java.lang.String src,
                                               boolean filterEmpty)

encodeCommaString

public static java.lang.String encodeCommaString(java.util.List list)
Convert a list of strings into a comma delimited list.

encodeCommaString

public static java.lang.String encodeCommaString(java.util.List list,
                                                 boolean filterEmpty)

decodeNewlineString

public static java.util.List decodeNewlineString(java.lang.String data,
                                                 boolean filterEmpty)
Given a newline deliminted string, break it up into a List of Strings.