public class StringUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EOL
The end-of-line string for the current platform.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
intField(int i,
int w)
Generates the string representation of an integer value,
left justified in a field of the specified width (using a space
as the padding character).
|
static int |
iVal(java.lang.String s,
java.lang.String errmsg)
Decode a String as an integer value, and output an error
message in the case of a format error.
|
static java.lang.String[] |
linesToAllStrings(java.lang.String lns)
Converts the given multi-line string into an array of strings,
retaining any blank lines present in the original.
|
static java.lang.String |
linesToOneString(java.lang.String[] lnstrs)
Converts the given array of strings representing lines into a
single multi-line string.
|
static java.lang.String |
linesToOneString(java.lang.String[] lnstrs,
int estlen)
Converts the given array of strings representing lines into a
single multi-line string.
|
static java.lang.String[] |
linesToStrings(java.lang.String lns)
Converts the given multi-line string into an array of strings
that excludes any blank lines.
|
static int |
nnProp(java.lang.String s,
java.lang.String ptag)
Finds and decodes a non-negative integer property value, as
defined in the given string.
|
static int |
nnVal(java.lang.String s,
int b,
java.lang.String errmsg)
Parses the given string to give a non-negative integer value
relative to the given base, and outputs an error message in
the case of a format error.
|
static int |
nnVal(java.lang.String s,
java.lang.String errmsg)
Parses the given string to give a non-negative integer value
(assuming base 10), and outputs an error message in the case of
a format error.
|
static java.lang.String[] |
readLines(java.io.InputStream ins)
Reads lines of text from the given input stream, returning them
as an array of strings.
|
static java.lang.String |
readText(java.io.InputStream ins)
Reads lines of text from the given input stream, and returns the
result as a single string in which adjacent lines are separated by
the platform line separator.
|
public static final java.lang.String EOL
public static java.lang.String intField(int i, int w)
i
- The integer value whose representation is required.w
- The required length for the result String.
Not expected to be negative (treated as zero if so).public static int nnVal(java.lang.String s, int b, java.lang.String errmsg)
s
- The string to be parsed.b
- The base relative to which s
is to be parsed.errmsg
- The error message to be displayed on the standard
error stream in the case of a NumberFormatException
,
or null
if no message is to be displayed.-1
in the case of a format error.public static int nnVal(java.lang.String s, java.lang.String errmsg)
s
- The string to be parsed.errmsg
- The error message to be displayed on the standard
error stream in the case of a NumberFormatException
,
or null
if no message is to be displayed.-1
in the case of a format error.public static int iVal(java.lang.String s, java.lang.String errmsg)
s
- The String to be decoded.errmsg
- The error message to be displayed on the standard
error stream in the case of a NumberFormatException,
or null
if no message is to be
displayed.public static int nnProp(java.lang.String s, java.lang.String ptag)
s
- The String to be searched (for a substring of the form
"ptag=NNNN"
).ptag
- The property name to be searched for.public static java.lang.String[] linesToStrings(java.lang.String lns)
lns
- The multi-line string to be converted.lns
.public static java.lang.String[] linesToAllStrings(java.lang.String lns)
lns
- The multi-line string to be converted.lns
.public static java.lang.String linesToOneString(java.lang.String[] lnstrs)
lnstrs
- The array of line strings.lnstrs
, using the standard line separator.public static java.lang.String linesToOneString(java.lang.String[] lnstrs, int estlen)
lnstrs
- The array of line strings.estlen
- An estimate of the average length of each line
(used to determine size of pre-allocated storage).lnstrs
, using the standard line separator.public static final java.lang.String readText(java.io.InputStream ins) throws java.io.IOException
ins
- The stream to be read (standard encoding assumed).java.io.IOException
- An I/O error occurred.public static final java.lang.String[] readLines(java.io.InputStream ins) throws java.io.IOException
ins
- The stream to be read (standard encoding assumed).java.io.IOException
- An I/O error occurred.