- java.lang.Object
-
- io.helidon.common.http.Utils
-
public final class Utils extends Object
Internal utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]toByteArray(ByteBuffer byteBuffer)Convert the given byte buffer to a byte array.static List<String>tokenize(char separator, String quoteChars, boolean includeEmptyTokens, String text)Tokenize providetextbyseparatorchar respecting quoted sub-sequences.static Stringunwrap(String str)Unwrap from double-quotes - if exists.static voidwrite(ByteBuffer byteBuffer, OutputStream out)Appends the content of the given byte buffer into the given output stream.
-
-
-
Method Detail
-
tokenize
public static List<String> tokenize(char separator, String quoteChars, boolean includeEmptyTokens, String text)
Tokenize providetextbyseparatorchar respecting quoted sub-sequences. Quoted sub-sequences are parts oftextwhich starts and ends by the samequoteChar.- Parameters:
separator- a token separator.quoteChars- characters which can be used for quoting. Quoted part must start and ends with the same character.includeEmptyTokens- return also tokens withlength == 0.text- a text to be tokenized.- Returns:
- A list of tokens without separator characters.
-
unwrap
public static String unwrap(String str)
Unwrap from double-quotes - if exists.- Parameters:
str- string to unwrap.- Returns:
- unwrapped string.
-
write
public static void write(ByteBuffer byteBuffer, OutputStream out) throws IOException
Appends the content of the given byte buffer into the given output stream.- Parameters:
out- the stream where to append the byte bufferbyteBuffer- the byte buffer to append to the stream- Throws:
IOException- in case of an IO problem
-
toByteArray
public static byte[] toByteArray(ByteBuffer byteBuffer)
Convert the given byte buffer to a byte array.- Parameters:
byteBuffer- byte buffer- Returns:
- byte array
-
-