Package io.helidon.media.common
Class ContentReaders
- java.lang.Object
-
- io.helidon.media.common.ContentReaders
-
public final class ContentReaders extends Object
Utility class that provides standalone mechanisms for reading message body content.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Reader<byte[]>
byteArrayReader()
Get a reader that converts aDataChunk
publisher to an array of bytes.static Reader<InputStream>
inputStreamReader()
Get a reader that converts aDataChunk
publisher to a blocking JavaInputStream
.static Single<byte[]>
readBytes(Flow.Publisher<DataChunk> chunks)
Collect theDataChunk
of the given publisher into a single byte array.static Single<String>
readString(Flow.Publisher<DataChunk> chunks, Charset charset)
static Single<String>
readURLEncodedString(Flow.Publisher<DataChunk> chunks, Charset charset)
static Reader<String>
stringReader(Charset charset)
static Reader<String>
urlEncodedStringReader(Charset charset)
-
-
-
Method Detail
-
readBytes
public static Single<byte[]> readBytes(Flow.Publisher<DataChunk> chunks)
Collect theDataChunk
of the given publisher into a single byte array.- Parameters:
chunks
- source publisher- Returns:
- Single
-
readString
public static Single<String> readString(Flow.Publisher<DataChunk> chunks, Charset charset)
- Parameters:
chunks
- source publishercharset
- charset to use for decoding the bytes- Returns:
- Single
-
readURLEncodedString
public static Single<String> readURLEncodedString(Flow.Publisher<DataChunk> chunks, Charset charset)
- Parameters:
chunks
- source publishercharset
- charset to use for decoding the input- Returns:
- Single
-
stringReader
public static Reader<String> stringReader(Charset charset)
- Parameters:
charset
- the charset to use with the returned string content reader- Returns:
- a string content reader
-
urlEncodedStringReader
public static Reader<String> urlEncodedStringReader(Charset charset)
- Parameters:
charset
- the charset to use with the returned string content reader- Returns:
- the URL-decoded string content reader
-
byteArrayReader
public static Reader<byte[]> byteArrayReader()
Get a reader that converts aDataChunk
publisher to an array of bytes.- Returns:
- reader that transforms a publisher of byte buffers to a completion stage that might end exceptionally with
-
inputStreamReader
public static Reader<InputStream> inputStreamReader()
Get a reader that converts aDataChunk
publisher to a blocking JavaInputStream
. The resultingCompletionStage
is already completed; however, the referencedInputStream
in 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
-
-