Package io.helidon.media.common
Class ContentReaders
- java.lang.Object
-
- io.helidon.media.common.ContentReaders
-
public final class ContentReaders extends Object
The ContentReaders.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Reader<byte[]>byteArrayReader()The returned reader provides means to convert aByteBufferpublisher to an array of bytes.static Reader<InputStream>inputStreamReader()Creates a reader that bridges Flow API IO to a blocking JavaInputStream.static Reader<String>stringReader(Charset charset)For basic charsets, returns a cachedStringContentReaderinstance or create a new instance otherwise.
-
-
-
Method Detail
-
stringReader
public static Reader<String> stringReader(Charset charset)
For basic charsets, returns a cachedStringContentReaderinstance or create a new instance otherwise.- Parameters:
charset- the charset to use with the returned string content reader- Returns:
- a string content reader
-
byteArrayReader
public static Reader<byte[]> byteArrayReader()
The returned reader provides means to convert aByteBufferpublisher to an array of bytes.Returns a lazily initialized classloader-scoped singleton.
Note that the singleton aspect is not guarantied by all JVMs. Although, Oracle JVM does create a singleton because the lambda does not capture values.
- Returns:
- the byte array content reader singleton that transforms a publisher of
byte buffers to a completion stage that might end exceptionally with
IllegalArgumentExceptionif it wasn't possible to convert the byte buffer to an array of bytes
-
inputStreamReader
public static Reader<InputStream> inputStreamReader()
Creates a reader that bridges Flow API IO to a blocking JavaInputStream. The resultingCompletionStageis already completed; however, the referencedInputStreamin it may not already have all the data available; in such case, the read method (e.g.,InputStream.read()) block.- Returns:
- a input stream content reader
-
-