public class StringUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static Optional<String> |
joinNonEmpty(String delimeter,
String... stringMaybeEmpty)
Like
String.join(java.lang.CharSequence, java.lang.CharSequence...) but ignores any empty strings, and returns Optional.empty() if
all components are empty. |
static String |
leftPad(String string,
int targetLength)
Left-pad a string with whitespace, so it reaches a fixed length.
|
static String |
rightPad(String string,
int targetLength)
Right-pad a string with whitespace, so it reaches a fixed length.
|
public static Optional<String> joinNonEmpty(String delimeter, String... stringMaybeEmpty)
String.join(java.lang.CharSequence, java.lang.CharSequence...)
but ignores any empty strings, and returns Optional.empty()
if
all components are empty.delimeter
- delimeter to use when joining stringsstringMaybeEmpty
- strings that may or may not be empty.public static String leftPad(String string, int targetLength)
string
- the string without padding.targetLength
- the desired total length of string, for which padding may be added.targetLength
unless it is already larger than targetLength
.public static String rightPad(String string, int targetLength)
string
- the string without padding.targetLength
- the desired total length of string, for which padding may be added.targetLength
unless it is already larger than targetLength
.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.