Class ContentReaders


  • public final class ContentReaders
    extends Object
    The ContentReaders.
    • Method Detail

      • stringReader

        public static Reader<String> stringReader​(Charset charset)
        For basic charsets, returns a cached StringContentReader instance 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 a ByteBuffer publisher 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 IllegalArgumentException if 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 Java InputStream. The resulting CompletionStage is already completed; however, the referenced InputStream 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