Package org.openjdk.jmc.common.util
Class StringToolkit
- java.lang.Object
- 
- org.openjdk.jmc.common.util.StringToolkit
 
- 
 public final class StringToolkit extends Object A toolkit for strings.
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static StringencodeFilename(String string)Encode a string so that it becomes safe to use as a file name.static Stringjoin(Object[] a, String delimiter)Joins 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 StringreadString(InputStream in)Reads 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.
 
- 
- 
- 
Method Detail- 
readStringpublic static String readString(InputStream in) throws IOException 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
 
 - 
readStringpublic static String readString(InputStream in, String charsetName) throws IOException Reads the contents of a stream with specified character encoding to a string.- Parameters:
- in- the stream to read from
- charsetName- the name of a supported- charset
- Returns:
- a string with the contents available from the stream
- Throws:
- IOException- if something went wrong
 
 - 
encodeFilenamepublic static String encodeFilename(String string) 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
 
 - 
joinpublic static String join(Collection<?> s, String delimiter) Joins items in collection to one string with delimiter between each item.- Parameters:
- s- collection of items
- delimiter- string to put between collection items
- Returns:
- a string joining all items in the collection with delimiter
 
 
- 
 
-