Package org.openjdk.jmc.common.util
Class StringToolkit
java.lang.Object
org.openjdk.jmc.common.util.StringToolkit
A toolkit for strings.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringencodeFilename(String string) Encode a string so that it becomes safe to use as a file name.static StringJoins items in an array to one string with delimiter between each item.static Stringjoin(Collection<?> s, String delimiter) Joins items in collection to one string with delimiter between each item.static StringReads the contents of a stream to a string, assuming UTF-8 encoding.static StringreadString(InputStream in, String charsetName) Reads the contents of a stream with specified character encoding to a string.static StringreadString(InputStream in, Charset charset) Reads the contents of a stream with specified character encoding to a string.
-
Method Details
-
readString
Reads the contents of a stream to a string, assuming UTF-8 encoding.- Parameters:
in- the stream to read from- Returns:
- a string with the contents available from the stream
- Throws:
IOException- if something went wrong
-
readString
Reads the contents of a stream with specified character encoding to a string.- Parameters:
in- the stream to read fromcharset- thecharset- Returns:
- a string with the contents available from the stream
- Throws:
IOException- if something went wrong
-
readString
Reads the contents of a stream with specified character encoding to a string.- Parameters:
in- the stream to read fromcharsetName- the name of a supportedcharset- Returns:
- a string with the contents available from the stream
- Throws:
IOException- if something went wrong
-
encodeFilename
Encode a string so that it becomes safe to use as a file name.- Parameters:
string- string to encode- Returns:
- a string usable as a file name
-
join
Joins items in collection to one string with delimiter between each item.- Parameters:
s- collection of itemsdelimiter- string to put between collection items- Returns:
- a string joining all items in the collection with delimiter
-
join
Joins items in an array to one string with delimiter between each item.- Parameters:
a- array of itemsdelimiter- string to put between collection items- Returns:
- a string joining all items in the array with delimiter
-