public final class Str
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bytesToString(byte[] bytes)
Convert specified array of bytes to String using default character encoding.
|
static java.lang.String |
bytesUtf8ToString(byte[] bytes)
Convert specified array of bytes to String using UTF-8 character encoding.
|
static java.lang.String |
bytesUtf8ToString(byte[] bytes,
int offset,
int length)
Convert specified array of bytes to String using UTF-8 character encoding.
|
static int |
countChar(java.lang.String str,
int start,
int end,
char ch)
Counts occurrences of a character in a string.
|
static boolean |
equal(java.lang.String left,
java.lang.String right)
Compares two strings.
|
static java.lang.String |
firstLine(java.lang.String text)
Return the first line from the specified text.
|
static java.lang.String |
formatMessage(java.lang.String message,
boolean removeUnused,
java.lang.Object... p)
Formats message that can contain up to nine optional parameters referred as &1 to &9.
|
static java.lang.String |
formatMessage(java.lang.String message,
java.lang.Object... p)
Formats message that can contain up to nine optional parameters referred as &1 to &9.
|
static byte[] |
getBytes(java.lang.String str)
Convert specified string to array of bytes using default character encoding.
|
static int |
getIntToken(java.lang.String text,
int tokenNr,
java.lang.String delimiters)
Returns a token from a text.
|
static java.lang.String |
getStackTrace(java.lang.Throwable t)
Deprecated.
Moved to class ifs.fnd.service.Util
|
static java.lang.String |
getStringToken(java.lang.String text,
int tokenNr,
java.lang.String delimiters)
Returns a token from a text.
|
static byte[] |
getUtf8Bytes(java.lang.String str)
Convert specified string to array of bytes using UTF-8 character encoding.
|
static int |
indexOf(java.lang.String str,
java.lang.String substr,
int fromIndex,
boolean ignoreCase)
Finds the first occurrence of a substring in a string.
|
static java.lang.String |
intToString(int value,
int digits)
Convert a specified integer into a String with the specified number of digits.
|
static boolean |
isEmpty(java.lang.String str)
Returns true if the specified string is null or is empty.
|
static int |
length(java.lang.String str)
Returns the length of a string or 0 if the string is null.
|
static boolean |
like(java.lang.String a,
java.lang.String b)
Returns a boolean value of the SQL expression "a like b".
|
static java.lang.String |
lpad(java.lang.String str,
int length)
Return given string left-padded with blanks to the specified length.
|
static java.lang.String |
lpad(java.lang.String str,
int length,
char ch)
Return given string left-padded to the specified length.
|
static java.lang.String |
nvl(java.lang.String str,
java.lang.String insteadOfNull)
Replaces a null value of a string.
|
static java.lang.String |
readFile(java.lang.String filename)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
readFile(java.lang.String filename,
java.lang.String encoding)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
readMessage(java.io.InputStream stream)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
readMessage(java.io.InputStream stream,
java.lang.String endOfMsg)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
readStream(java.io.InputStream stream)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
readStream(java.io.Reader stream)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
replace(java.lang.String str,
java.lang.String substr,
java.lang.String with)
Returns the specified 'str' string with all occurrences of 'substr'
replaced with 'with'.
|
static java.lang.String |
replace(java.lang.String str,
java.lang.String substr,
java.lang.String with,
boolean ignoreCase)
Returns the specified 'str' string with all occurrences of 'substr'
replaced with 'with'.
|
static java.lang.String |
replaceFirst(java.lang.String str,
java.lang.String substr,
java.lang.String with)
Returns the specified 'str' string with the first occurrence of 'substr'
replaced with 'with'.
|
static java.lang.String |
rpad(java.lang.String str,
int length)
Return given string rigth-padded with blanks to the specified length.
|
static java.lang.String |
rpad(java.lang.String str,
int length,
char ch)
Return given string rigth-padded to the specified length.
|
static void |
showException(java.lang.Throwable ex)
Deprecated.
Moved to class ifs.fnd.service.Util
|
static java.lang.String[] |
split(java.lang.String str,
java.lang.String delimChars)
Split a string into tokens.
|
static int |
toInt(java.lang.String str)
Converts the specified string to an integer value.
|
static java.lang.String |
trimLine(java.lang.String value)
Remove trailing whitespace from a string.
|
static void |
writeFile(java.lang.String filename,
java.lang.String text)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
public static java.lang.String replace(java.lang.String str, java.lang.String substr, java.lang.String with)
str
- a String to search and replace insubstr
- old substringwith
- new substringpublic static java.lang.String replace(java.lang.String str, java.lang.String substr, java.lang.String with, boolean ignoreCase)
str
- a String to search and replace insubstr
- old substringwith
- new substringignoreCase
- if true, ignore case when comparing characterspublic static java.lang.String replaceFirst(java.lang.String str, java.lang.String substr, java.lang.String with)
str
- a String to search and replace insubstr
- old substringwith
- new substringpublic static java.lang.String trimLine(java.lang.String value)
value
- a string to trimpublic static java.lang.String lpad(java.lang.String str, int length)
public static java.lang.String lpad(java.lang.String str, int length, char ch)
public static java.lang.String rpad(java.lang.String str, int length)
public static java.lang.String rpad(java.lang.String str, int length, char ch)
public static java.lang.String nvl(java.lang.String str, java.lang.String insteadOfNull)
str
- a string which may have a null valueinsteadOfNull
- default value returned if the first parameter is nullpublic static boolean isEmpty(java.lang.String str)
str
- a String to checkpublic static boolean equal(java.lang.String left, java.lang.String right)
left
- first string to compareright
- second string to comparepublic static int length(java.lang.String str)
str
- a Stringpublic static int countChar(java.lang.String str, int start, int end, char ch)
str
- string to search the specified character instart
- the index to start the search from, inclusiveend
- the index to end the search at, exclusivech
- character to count occurrences ofpublic static int toInt(java.lang.String str)
str
- a String to parsepublic static java.lang.String intToString(int value, int digits)
value
- an integer to convertdigits
- the number of digits to generatepublic static byte[] getBytes(java.lang.String str)
str
- string to be convertedpublic static byte[] getUtf8Bytes(java.lang.String str)
str
- string to be convertedpublic static java.lang.String bytesToString(byte[] bytes)
bytes
- the array to be convertedpublic static java.lang.String bytesUtf8ToString(byte[] bytes)
bytes
- the array to be convertedpublic static java.lang.String bytesUtf8ToString(byte[] bytes, int offset, int length)
bytes
- The bytes to be decoded into charactersoffset
- The index of the first byte to decodelength
- The number of bytes to decodepublic static java.lang.String firstLine(java.lang.String text)
text
- a textpublic static boolean like(java.lang.String a, java.lang.String b)
"*" as match-any character (instead of "%") "?" as match-one character (instead of "_")
a
- a string to match to the patternb
- a pattern with wildcards characterspublic static java.lang.String formatMessage(java.lang.String message, java.lang.Object... p)
message
- p
- public static java.lang.String formatMessage(java.lang.String message, boolean removeUnused, java.lang.Object... p)
message
- removeUnused
- p
- public static java.lang.String getStringToken(java.lang.String text, int tokenNr, java.lang.String delimiters) throws java.io.IOException
text
- a text to tokenizetokenNr
- the ordinal number of the token to returndelimiters
- delimiter characters used to tokenize the textjava.io.IOException
- if an I/O error occurspublic static int getIntToken(java.lang.String text, int tokenNr, java.lang.String delimiters) throws java.io.IOException
text
- a text to tokenizetokenNr
- the ordinal number of the token to returndelimiters
- delimiter characters used to tokenize the textjava.io.IOException
- if an I/O error occurspublic static java.lang.String[] split(java.lang.String str, java.lang.String delimChars)
str
- a string to splitdelimChars
- delimiter characters used to tokenize the stringpublic static int indexOf(java.lang.String str, java.lang.String substr, int fromIndex, boolean ignoreCase)
str
- string to search insubstr
- substring to search forfromIndex
- index from which to start the searchignoreCase
- if true, ignore case when comparing characters-1
if there is no such occurrence.public static java.lang.String getStackTrace(java.lang.Throwable t)
t
- a ThrowableUtil.getStackTrace(java.lang.Throwable)
public static void showException(java.lang.Throwable ex)
ex
- an exceptionUtil.showException(java.lang.Throwable)
public static java.lang.String readFile(java.lang.String filename) throws java.io.IOException
filename
- a file namejava.io.IOException
- if an I/O error occursIoUtil.readFile(java.lang.String)
public static java.lang.String readFile(java.lang.String filename, java.lang.String encoding) throws java.io.IOException
filename
- a file nameencoding
- character encodingjava.io.IOException
- if an I/O error occursIoUtil.readFile(java.lang.String, java.lang.String)
public static java.lang.String readStream(java.io.InputStream stream) throws java.io.IOException
stream
- an open InputStreamjava.io.IOException
- if an I/O error occursIoUtil.readStream(java.io.InputStream)
public static java.lang.String readStream(java.io.Reader stream) throws java.io.IOException
stream
- an open Readerjava.io.IOException
- if an I/O error occursIoUtil.readStream(java.io.Reader)
public static java.lang.String readMessage(java.io.InputStream stream, java.lang.String endOfMsg) throws java.io.IOException
stream
- an open streamendOfMsg
- end-of-msg markerjava.io.IOException
- if an I/O error occursIoUtil.readMessage(java.io.InputStream, java.lang.String)
public static java.lang.String readMessage(java.io.InputStream stream) throws java.io.IOException
stream
- an open streamjava.io.IOException
- if an I/O error occursIoUtil.readStream(java.io.InputStream)
public static void writeFile(java.lang.String filename, java.lang.String text) throws java.io.IOException
filename
- file nametext
- file contentsjava.io.IOException
- if an I/O error occursIoUtil.writeFileCrLf(java.lang.String, java.lang.String)