Class StringBuilderWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable, java.lang.CharSequence

    public class StringBuilderWriter
    extends java.io.Writer
    implements java.lang.CharSequence
    Class to wrap a StringBuilder to implement the Writer interface.
    Since:
    1.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      StringBuilderWriter​(java.lang.StringBuilder stringBuilder)
      Constructs a new writer with the provided StringBuilder to write to.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.Writer append​(char c)  
      java.io.Writer append​(java.lang.CharSequence cSeq)  
      java.io.Writer append​(java.lang.CharSequence cSeq, int start, int end)  
      char charAt​(int index)  
      void close()  
      void flush()  
      int length()  
      java.lang.CharSequence subSequence​(int start, int end)  
      void write​(char[] cbuf)  
      void write​(char[] cbuf, int offset, int len)  
      void write​(int c)  
      • Methods inherited from class java.io.Writer

        nullWriter, write, write
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints, toString
    • Constructor Detail

      • StringBuilderWriter

        public StringBuilderWriter​(java.lang.StringBuilder stringBuilder)
        Constructs a new writer with the provided StringBuilder to write to.
        Parameters:
        stringBuilder - string builder to write to, can not be null
    • Method Detail

      • append

        public java.io.Writer append​(char c)
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.Writer
      • append

        public java.io.Writer append​(java.lang.CharSequence cSeq)
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.Writer
      • append

        public java.io.Writer append​(java.lang.CharSequence cSeq,
                                     int start,
                                     int end)
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.Writer
      • write

        public void write​(int c)
        Overrides:
        write in class java.io.Writer
      • write

        public void write​(char[] cbuf)
        Overrides:
        write in class java.io.Writer
      • write

        public void write​(char[] cbuf,
                          int offset,
                          int len)
        Specified by:
        write in class java.io.Writer
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence