Class spt.util.StringUtil
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class spt.util.StringUtil

java.lang.Object
   |
   +----spt.util.StringUtil

public class StringUtil
extends Object
A variety of String related utility functions.

Constructor Index

 o StringUtil()

Method Index

 o cgiParamToStrings(String)
Convert single string in CGI parameter format to an array of 2 strings.
 o cgiParams()
Read System.in and convert CGI-format parameters to a Hashtable of name/value pairs.
 o cgiParams(int)
Read System.in and convert CGI-format parameters to a Hashtable of name/value pairs.
 o fractionalToFloat(String)
Convert a fractional String to it's decimal equivalent.
 o hashtableFromString(String)
Converts a String to a Hashtable.
 o indexOfMatched(String, int)
Returns the index of the matching '{', '[' or '(' character in the given String.
 o readString(DataInput)
Read a String from a DataInput source.
 o split(String, String)
Convert a delimited String to an array of elements using the specified delimiter set.
 o split(String)
Convert a pipe delimited String to an array of elements.
 o stringFromFile(String)
Create a string initialized with the contents of a file.
 o stringToColor(String)
Parse a String and return a Color.
 o toFile(String, String)
Store a String in its own file.
 o writeString(DataOutput, String)
Write a String to a DataOutput source.

Constructors

 o StringUtil
  public StringUtil()

Methods

 o split
  public static String[] split(String s,
                               String delimSet)
Convert a delimited String to an array of elements using the specified delimiter set.
See Also:
StringTokenizer
 o split
  public static String[] split(String s)
Convert a pipe delimited String to an array of elements.
See Also:
StringTokenizer
 o stringToColor
  public static Color stringToColor(String s)
Parse a String and return a Color. The following formats are recognized: "#FFFFFF", "r,g,b" and one of a number known case-independent strings (e.g. "red", "black", etc.).
See Also:
Color
 o cgiParamToStrings
  public static String[] cgiParamToStrings(String s)
Convert single string in CGI parameter format to an array of 2 strings. The 0th element is the parameter name and the 1st element is the parameter value.
See Also:
cgiParams
 o cgiParams
  public static Hashtable cgiParams()
Read System.in and convert CGI-format parameters to a Hashtable of name/value pairs. The length of the data to be read is determined by the property CONTENT_LENGTH (preferably) or, if not present, by the number of bytes available to read.
See Also:
Hashtable, getProperty
 o cgiParams
  public static Hashtable cgiParams(int content_length)
Read System.in and convert CGI-format parameters to a Hashtable of name/value pairs. The length of the data to be read is determined by content_length.
See Also:
Hashtable
 o writeString
  public static void writeString(DataOutput d,
                                 String s) throws IOException
Write a String to a DataOutput source. Strings are transmitted as an int, the length, followed by the bytes of the String itself.
See Also:
DataOutput
 o readString
  public static String readString(DataInput d) throws IOException
Read a String from a DataInput source. The String must have been sent by StringUtil.writeString.
See Also:
DataInput
 o fractionalToFloat
  public static float fractionalToFloat(String s) throws NumberFormatException
Convert a fractional String to it's decimal equivalent. e.g. "2 1/4".
 o stringFromFile
  public static String stringFromFile(String file) throws IOException
Create a string initialized with the contents of a file.
 o toFile
  public static void toFile(String s,
                            String file) throws IOException
Store a String in its own file.
 o indexOfMatched
  public static int indexOfMatched(String s,
                                   int startAt)
Returns the index of the matching '{', '[' or '(' character in the given String. The char to be matched must be in position startAt in the string.
 o hashtableFromString
  public static Hashtable hashtableFromString(String s)
Converts a String to a Hashtable. The String must have been produced by Hastable.toString(). This method converts both the key and value to objects of type String. Useful for writing out Hashtables to permanent storage and then reading them back in.

Warning: This will fail miserably if any of the keys or values have '=' chars in them.

See Also:
toString

All Packages  Class Hierarchy  This Package  Previous  Next  Index