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.
-
StringUtil()
-
-
cgiParamToStrings(String)
- Convert single string in CGI parameter format to an
array of 2 strings.
-
cgiParams()
- Read System.in and convert CGI-format parameters to a
Hashtable of name/value pairs.
-
cgiParams(int)
- Read System.in and convert CGI-format parameters to a
Hashtable of name/value pairs.
-
fractionalToFloat(String)
- Convert a fractional String to it's decimal
equivalent.
-
hashtableFromString(String)
- Converts a String to a Hashtable.
-
indexOfMatched(String, int)
- Returns the index of the matching '{', '[' or '(' character
in the given String.
-
readString(DataInput)
- Read a String from a DataInput source.
-
split(String, String)
- Convert a delimited String to an array of elements
using the specified delimiter set.
-
split(String)
- Convert a pipe delimited String to an array of elements.
-
stringFromFile(String)
- Create a string initialized with the contents of a file.
-
stringToColor(String)
- Parse a String and return a Color.
-
toFile(String, String)
- Store a String in its own file.
-
writeString(DataOutput, String)
- Write a String to a DataOutput source.
StringUtil
public StringUtil()
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
split
public static String[] split(String s)
- Convert a pipe delimited String to an array of elements.
- See Also:
- StringTokenizer
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
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
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
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
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
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
fractionalToFloat
public static float fractionalToFloat(String s) throws NumberFormatException
- Convert a fractional String to it's decimal
equivalent. e.g. "2 1/4".
stringFromFile
public static String stringFromFile(String file) throws IOException
- Create a string initialized with the contents of a file.
toFile
public static void toFile(String s,
String file) throws IOException
- Store a String in its own file.
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.
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