public class StringUtils extends Object
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
fixFileSeparatorChar(String arg)
Fixes the file separator char for the target platform
using the following replacement.
|
static boolean |
isQuoted(String argument)
Determines if this is a quoted argument - either single or
double quoted.
|
static String |
quoteArgument(String argument)
Put quotes around the given String if necessary.
|
static String[] |
split(String input,
String splitChar)
Split a string into an array of strings based
on a separator.
|
static StringBuffer |
stringSubstitution(String argStr,
Map<? super String,?> vars,
boolean isLenient)
Perform a series of substitutions.
|
static String |
toString(String[] strings,
String separator)
Concatenates an array of string using a separator.
|
public static StringBuffer stringSubstitution(String argStr, Map<? super String,?> vars, boolean isLenient)
The substitutions are performed by replacing ${variable} in the target string with the value of provided by the key "variable" in the provided hash table.
A key consists of the following characters:
argStr
- the argument string to be processedvars
- name/value pairs used for substitutionisLenient
- ignore a key not found in vars or throw a RuntimeException?public static String[] split(String input, String splitChar)
input
- what to splitsplitChar
- what to split onpublic static String fixFileSeparatorChar(String arg)
arg
- the argument to fixpublic static String toString(String[] strings, String separator)
strings
- the strings to concatenateseparator
- the separator between two stringspublic static String quoteArgument(String argument)
If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
argument
- the argument to be quotedIllegalArgumentException
- If argument contains both types of quotespublic static boolean isQuoted(String argument)
argument
- the argument to checkCopyright © 2023 The Apache Software Foundation. All rights reserved.