类 StringBuilderWriter

java.lang.Object
java.io.Writer
com.baidu.bjf.remoting.protobuf.utils.StringBuilderWriter
所有已实现的接口:
Closeable, Flushable, Appendable, AutoCloseable

public class StringBuilderWriter extends Writer
A character stream that collects its output in a string buffer, which can then be used to construct a string.

Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

从以下版本开始:
1.12.0
作者:
xiemalin
  • 构造器详细资料

    • StringBuilderWriter

      public StringBuilderWriter()
      Create a new string writer using the default initial string-buffer size.
    • StringBuilderWriter

      public StringBuilderWriter(int initialSize)
      Create a new string writer using the specified initial string-buffer size.
      参数:
      initialSize - The number of char values that will fit into this buffer before it is automatically expanded
      抛出:
      IllegalArgumentException - If initialSize is negative
  • 方法详细资料

    • write

      public void write(int c)
      Write a single character.
      覆盖:
      write 在类中 Writer
      参数:
      c - the c
    • write

      public void write(char[] cbuf, int off, int len)
      Write a portion of an array of characters.
      指定者:
      write 在类中 Writer
      参数:
      cbuf - Array of characters
      off - Offset from which to start writing characters
      len - Number of characters to write
    • write

      public void write(String str)
      Write a string.
      覆盖:
      write 在类中 Writer
      参数:
      str - the str
    • write

      public void write(String str, int off, int len)
      Write a portion of a string.
      覆盖:
      write 在类中 Writer
      参数:
      str - String to be written
      off - Offset from which to start writing characters
      len - Number of characters to write
    • append

      public StringBuilderWriter append(CharSequence csq)
      Appends the specified character sequence to this writer.

      An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation

       out.write(csq.toString())
       

      Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

      指定者:
      append 在接口中 Appendable
      覆盖:
      append 在类中 Writer
      参数:
      csq - The character sequence to append. If csq is null, then the four characters "null" are appended to this writer.
      返回:
      This writer
      从以下版本开始:
      1.5
    • append

      public StringBuilderWriter append(CharSequence csq, int start, int end)
      Appends a subsequence of the specified character sequence to this writer.

      An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

       out.write(csq.subSequence(start, end).toString())
       
      指定者:
      append 在接口中 Appendable
      覆盖:
      append 在类中 Writer
      参数:
      csq - The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
      start - The index of the first character in the subsequence
      end - The index of the character following the last character in the subsequence
      返回:
      This writer
      抛出:
      IndexOutOfBoundsException - If start or end are negative, start is greater than end, or end is greater than csq.length()
      从以下版本开始:
      1.5
    • append

      public StringBuilderWriter append(char c)
      Appends the specified character to this writer.

      An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

       out.write(c)
       
      指定者:
      append 在接口中 Appendable
      覆盖:
      append 在类中 Writer
      参数:
      c - The 16-bit character to append
      返回:
      This writer
      从以下版本开始:
      1.5
    • toString

      public String toString()
      Return the buffer's current value as a string.
      覆盖:
      toString 在类中 Object
      返回:
      the string
    • getBuffer

      public StringBuilder getBuffer()
      Gets the buffer.
      返回:
      the buffer
    • flush

      public void flush()
      Flush the stream.
      指定者:
      flush 在接口中 Flushable
      指定者:
      flush 在类中 Writer
    • close

      public void close() throws IOException
      Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      指定者:
      close 在类中 Writer
      抛出:
      IOException - Signals that an I/O exception has occurred.