|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--texsoft.java.util.XsStrUtil
This abstract class provides some usefull methods to manipulate String
objects.
Constructor Summary | |
XsStrUtil()
|
Method Summary | |
static java.lang.String |
leftPad(java.lang.String s,
char ch,
int width)
Returns s left padded with ch to width legnth. |
static void |
main(java.lang.String[] args)
Some test code. |
static java.lang.String |
rightPad(java.lang.String s,
char ch,
int width)
Returns s right padded with ch to width length. |
static java.lang.String |
sequenceOf(char ch,
int n)
Returns a new String made by a sequence of n characters ch. |
static java.lang.String[] |
split(java.lang.String s,
char sep)
Split s into substrings separed by the sep char . |
static java.lang.String |
zeroPad(long value,
int width)
Convert value to String
left padding with '0' to width length. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XsStrUtil()
Method Detail |
public static java.lang.String zeroPad(long value, int width)
String
left padding with '0'
to width length.
value
- long
to convert into string left pdded with '0'
.width
- if the lenght of the string conversion of value is less than width,
fill to left with '0'
characters so that the resulting string will
have width length.
String
and left padded with '0'
characters up to width length.public static java.lang.String[] split(java.lang.String s, char sep)
char
.
Returns the substrings into a String[]
. Two consecutive sep
chararcters will resolve into an zero-lenght substring. A leading or trailing
sep character will generate a zero-lenght substring too.
Here are some examples:
split("abc-12-xx", '-') -> { "abc", "12", "xx" } split("A/B//F", "/") -> { "A", "B", "", "F" } split("onlyone", ",") -> { "onlyone" }
s
- the string to be split.sep
- the char that is used as split marker into the string.
String[]
with the substrings.public static java.lang.String sequenceOf(char ch, int n)
String
made by a sequence of n characters ch.
ch
- build the string with this char
.n
- how many ch char
s to put into the string.
String
made by n ch characters.public static java.lang.String leftPad(java.lang.String s, char ch, int width)
s
- string to be left padded.ch
- use this char
to left pad the string.width
- minimum width of the string; if the string's length
is less that width, the it will
be left padded with ch.
public static java.lang.String rightPad(java.lang.String s, char ch, int width)
s
- string to be right padded.ch
- use this char
to right pad the string.width
- minimum width of the string; if the string's
length is less that width, the it will
be right padded with ch.
public static void main(java.lang.String[] args)
args
- command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |