Class CharSequenceInputStream.Builder

  • All Implemented Interfaces:
    IOSupplier<CharSequenceInputStream>
    Enclosing class:
    CharSequenceInputStream

    public static class CharSequenceInputStream.Builder
    extends AbstractStreamBuilder<CharSequenceInputStream,​CharSequenceInputStream.Builder>
    Builds a new CharSequenceInputStream instance.

    For example:

    Using a Charset

    
     CharSequenceInputStream s = CharSequenceInputStream.builder()
       .setBufferSize(8192)
       .setCharSequence("String")
       .setCharset(Charset.defaultCharset())
       .get();
     

    Using a CharsetEncoder

    
     CharSequenceInputStream s = CharSequenceInputStream.builder()
       .setBufferSize(8192)
       .setCharSequence("String")
       .setCharsetEncoder(Charset.defaultCharset().newEncoder()
         .onMalformedInput(CodingErrorAction.REPLACE)
         .onUnmappableCharacter(CodingErrorAction.REPLACE))
       .get();
     
    Since:
    2.13.0
    • Field Detail

      • charsetEncoder

        private java.nio.charset.CharsetEncoder charsetEncoder
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • get

        public CharSequenceInputStream get()
        Constructs a new instance.

        This builder use the aspects the CharSequence, buffer size, and Charset.

        Returns:
        a new instance.
        Throws:
        java.lang.IllegalArgumentException - if the buffer is not large enough to hold a complete character.
      • getCharsetEncoder

        java.nio.charset.CharsetEncoder getCharsetEncoder()
      • setCharsetEncoder

        public CharSequenceInputStream.Builder setCharsetEncoder​(java.nio.charset.CharsetEncoder newEncoder)
        Sets the charset encoder. Assumes that the caller has configured the encoder.
        Parameters:
        newEncoder - the charset encoder.
        Returns:
        this
        Since:
        2.13.0