@StableMinor(version="12.0", sinceVersion="4.0") public class TextUtil extends Object
Constructor and Description |
---|
TextUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
copyFile(String sourceFile,
String targetFile) |
static String |
escapeJs(String javascriptString)
Escapes a javascript string so it can added to inside quotes without breaking the javascript code.
|
static String |
escapeLocalizationParameter(String str)
Escapes a localization parameter string.
|
static String |
escapeRegexpReplacement(String replacementString)
Escapes regexp replacement commands in a string for use as replacement.
|
static FileWriter |
getFileWriter(String filename,
boolean append)
Deprecated.
Since 4.0.9
because this method uses the system default charset encoding.
|
static int |
indexOfCaseInsensitive(StringBuilder source,
String findStr) |
static int |
indexOfCaseInsensitive(StringBuilder source,
String findStr,
int fromIndex) |
static String |
joinStringArray(String[] array,
String delim) |
static StringBuffer |
joinStringArray(String[] array,
String delim,
StringBuffer sb) |
static String |
joinStringCollection(Collection<String> strings,
String delim)
Generates a string joining the strings in the collection with the
delimiter specified between them.
|
static String |
joinStringCollectionUserFriendly(List<String> listItems)
Build a list, separating terms with the locale-defined separator.
|
static String |
leftPad(String s,
int minimumLength,
char fillingChar) |
static String |
read(InputStream in,
String encoding)
Reads an input stream as a string using the given encoding.
|
static String |
read(Reader reader)
Reads the data from the reader until its end is reached.
|
static String |
read(URL url,
String encoding)
Reads the
InputStream provided by the given
URL as a string. |
static String |
readFile(String filename)
Deprecated.
This method uses the system default encoding, which if diferent
from the file's encoding may cause data corruption. Instead of using
this method use
readFile(String, String) specifying the correct
encoding. |
static String |
readFile(String filename,
String encoding) |
static String |
stringRepeat(char ch,
int count)
Generate a string repeating the 'ch' character 'count' times.
|
static String |
stringReplace(String str,
String target,
String replacement) |
static String |
stringReplace(String str,
String target,
String replacement,
boolean replaceOnlyFirstOccurrence) |
static void |
writeFile(String filename,
String content,
boolean append)
Deprecated.
Since 4.0.8, use
writeFile(String, String, String, boolean)
because this method uses the system default charset encoding. |
static void |
writeFile(String filename,
String content,
String charset,
boolean append) |
public static String stringReplace(String str, String target, String replacement)
str
- is the original String which may contain substring target.target
- is the substring which is to be replaced.replacement
- is the replacement for target.public static String stringReplace(String str, String target, String replacement, boolean replaceOnlyFirstOccurrence)
public static String escapeRegexpReplacement(String replacementString)
replacementString
- the replacement string.public static String escapeJs(String javascriptString)
Single quotes, double quotes, '\', next line and line feed characters are escaped.
javascriptString
- the javacript string raw value.public static String escapeLocalizationParameter(String str)
str
- the string to escape.public static String joinStringCollection(Collection<String> strings, String delim)
strings
- the collectino with the strings.delim
- the delimiter.public static StringBuffer joinStringArray(String[] array, String delim, StringBuffer sb)
@Deprecated public static String readFile(String filename) throws FileNotFoundException, IOException
readFile(String, String)
specifying the correct
encoding.filename
- the filename.FileNotFoundException
IOException
public static String readFile(String filename, String encoding) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public static String read(URL url, String encoding) throws IOException
InputStream
provided by the given
URL
as a string.url
- the URL.encoding
- the encoding to use for reading.IOException
- if an I/O exception occurs.URL.openStream()
,
read(InputStream, String)
public static String read(InputStream in, String encoding) throws IOException
in
- the input stream.encoding
- the encoding.IOException
- if an I/O exception occurs.public static String read(Reader reader) throws IOException
reader
- the reader.IOException
- if an I/O error occurs.@Deprecated public static void writeFile(String filename, String content, boolean append) throws IOException
writeFile(String, String, String, boolean)
because this method uses the system default charset encoding.IOException
public static void writeFile(String filename, String content, String charset, boolean append) throws IOException, PortalException
IOException
PortalException
public static void copyFile(String sourceFile, String targetFile) throws IOException
IOException
@Deprecated public static FileWriter getFileWriter(String filename, boolean append) throws IOException
IOException
public static int indexOfCaseInsensitive(StringBuilder source, String findStr)
public static int indexOfCaseInsensitive(StringBuilder source, String findStr, int fromIndex)
public static String stringRepeat(char ch, int count)
ch
- The character to be repeatedcount
- The number of repetitionspublic static String joinStringCollectionUserFriendly(List<String> listItems) throws PortalException
listItems
- PortalException
LumisXP 12.0.0.190809 - Copyright © 2006–2019 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.