public class StringUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
arrayToString(int[] array)
Retrieves a String with the values of the given array.
|
static java.lang.String |
arrayToString(java.lang.Object[] array)
Retrieves a String with the values of the given array.
|
static java.lang.String |
arrayToString(short[] array)
Retrieves a String with the values of the given array.
|
static boolean |
contains(java.lang.String s1,
java.lang.String s2)
Tests if one String contains another.
|
static boolean |
equalsIgnoreCase(java.lang.String string1,
java.lang.String string2)
Checks if the
string1 equals the string2 ignoring the
letter case. |
static java.lang.String |
filterAlphaNumeric(java.lang.String data)
Filter out Non-AlphaNumeric characters from a given string.
|
static java.lang.String |
filterNumbers(java.lang.String data)
Filter out everything but numeric characters from a given string.
|
static java.lang.String |
formatCSV(java.lang.String value)
Formats a string for inclusion in a CSV formatted file.
|
static java.lang.String |
removeChar(java.lang.String s,
char c)
Removes all of a particular character from a String.
|
static java.lang.String |
replace(java.lang.String str,
java.lang.String pattern,
java.lang.String replace)
Replaces the given patter in the given string with the given value.
|
static java.lang.String |
segment(java.lang.String data,
int segmentLength,
java.lang.String tokenizer)
Takes a plain string and divides the string into segments.
|
static java.lang.String[] |
split(java.lang.String original,
java.lang.String separator)
Splits the given string using the given separator.
|
static java.lang.String |
toSpecificLength(java.lang.String s,
int len)
Makes a String a specific length.
|
static java.lang.String |
toSpecificLength(java.lang.String s,
int len,
boolean left)
Makes a String a specific length.
|
static java.lang.String |
truncate(java.lang.String s,
int l)
Truncates a String to a specified length, if necessary.
|
static java.lang.String |
wrapLines(java.lang.String s,
int l,
java.lang.String prefix)
Wraps a String to lines of a particular length, adding a prefix
to each line.
|
static java.lang.String |
wrapWords(java.lang.String s,
int l,
java.lang.String prefix)
Wraps String to lines of at most particular length, avoiding
breaking up words, and adding a prefix to each line.
|
public static java.lang.String arrayToString(int[] array)
array - Array to create string from.public static java.lang.String arrayToString(java.lang.Object[] array)
array - Array to create string from.public static java.lang.String arrayToString(short[] array)
array - Array to create string from.public static boolean contains(java.lang.String s1,
java.lang.String s2)
s1 - The enclosing String.s2 - The String to look for in s1.true if s1 contains s2, false otherwise.public static boolean equalsIgnoreCase(java.lang.String string1,
java.lang.String string2)
string1 equals the string2 ignoring the
letter case.string1 - String 1 to compare.string2 - String 2 to compare.true if string1 equals string2 ignoring
the letter case.public static java.lang.String filterAlphaNumeric(java.lang.String data)
data - the string to filter.public static java.lang.String filterNumbers(java.lang.String data)
data - the string to filter.public static java.lang.String formatCSV(java.lang.String value)
value - the value to store in the CSV filepublic static java.lang.String removeChar(java.lang.String s,
char c)
s - the String to remove characters from.c - the char to remove from ss with all characters
c removed.public static java.lang.String replace(java.lang.String str,
java.lang.String pattern,
java.lang.String replace)
str - String where replacements will take place.pattern - Pattern to replace.replace - String that will replace the pattern.public static java.lang.String segment(java.lang.String data,
int segmentLength,
java.lang.String tokenizer)
data - String to divide in segments.segmentLength - Length of each segment.tokenizer - Character to set between each segment.public static java.lang.String[] split(java.lang.String original,
java.lang.String separator)
original - Original string to split.separator - The char to use as splitter.public static java.lang.String toSpecificLength(java.lang.String s,
int len)
If the original String is too short, it adds spaces.
If the original String is too long, it truncates the String.
If the original String is null, then l spaces will be returned.
s - the String to make a specific length.len - the length to make the String.public static java.lang.String toSpecificLength(java.lang.String s,
int len,
boolean left)
If the original String is too short, it adds spaces.
If the original String is too long, it truncates the String.
If the original String is null, then l spaces will be returned.
s - the String to make a specific length.len - the length to make the String.left - true if the text should be left aligned,
false if the text should be right aligned.public static java.lang.String truncate(java.lang.String s,
int l)
s - the String to truncate to.l - the Length to truncate to.s.length() is greater than l,
returns s truncated to l characters;
otherwise, returns s.public static java.lang.String wrapLines(java.lang.String s,
int l,
java.lang.String prefix)
s - the String to wrap the lines of.l - the length of each line.prefix - the String prefix to add to the beginning of each line.public static java.lang.String wrapWords(java.lang.String s,
int l,
java.lang.String prefix)
s - the String to wrap the lines of.l - the maximum length of each line.
Must be >= 1.prefix - prefix to be added.java.lang.IllegalArgumentException - if l < 1.© Copyright 2014 Etherios, Inc. All rights reserved. Etherios, Inc. is a Division of Digi International Inc.