public class Strings extends Object
| Constructor and Description |
|---|
Strings() |
| Modifier and Type | Method and Description |
|---|---|
static String |
addLineNumbers(String text)
Helper method to add line numbers to a string
|
static String |
addLineNumbers(String text,
int startLine) |
static String |
addPadding(String pad,
int n)
Add n pad characters to pad.
|
static String |
crop(String text,
int maxLength)
Crop the text in the middle if too long.
|
static String |
getFileSep()
Get local fashion for file separators (e.g.
|
static String |
getNl()
Get local fashion for newlines.
|
static String |
getPathSep()
Get local fashion for path separators (e.g.
|
static String |
humanReadableByteCount(long bytes,
boolean base10)
Converts a size given as a number of bytes (e.g.
|
static Map<String,String> |
toMap(String string)
Get back a Map of String*String from its String representation.
|
static LinkedHashSet<String> |
toSet(String string,
String separator)
Get back a Set of String from its String representation.
|
static String |
toString(LinkedHashSet<String> set)
Create a String representation of a Set of String with the format
[value, value].
|
static String |
toString(Map<String,String> map)
Create a String representation of a Map of String*String with the format
{key=value, key=value}.
|
static String |
toString(Object object)
Convert about any object to a human readable string.
Use Arrays.deepToString(Object[]) to convert an array or
a collection. |
static String |
unescape(String str)
A method to unescape Java strings, returning a string containing escape
sequences into the respective character.
|
public static String getNl()
public static String getPathSep()
public static String getFileSep()
public static String addLineNumbers(String text)
public static String unescape(String str)
str - the string to unescapepublic static String humanReadableByteCount(long bytes, boolean base10)
bytes - the size to be converted.base10 - if true then the multiplier used is 10^3 (i.e.
1000 bytes are reported as 1kB, etc.); otherwise 1024 is used as a
multiplier (1024 bytes is 1KiB, etc.).public static String toString(Object object)
Arrays.deepToString(Object[]) to convert an array or
a collection.object - object to be converted to a stringpublic static String toString(LinkedHashSet<String> set)
set - set to convert to one StringtoSet(String, String)public static String toString(Map<String,String> map)
map - map to convert to one StringtoMap(String)public static LinkedHashSet<String> toSet(String string, String separator)
string - String to convert to a Listseparator - String that delimits the element of the settoString(java.util.LinkedHashSet)public static Map<String,String> toMap(String string)
string - String to convert to a MaptoString(java.util.Map)Copyright © 2024 GATE. All rights reserved.