类 StringBuilderWriter
- 所有已实现的接口:
Closeable,Flushable,Appendable,AutoCloseable
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
-
字段概要
-
构造器概要
构造器构造器说明Create a new string writer using the default initial string-buffer size.StringBuilderWriter(int initialSize) Create a new string writer using the specified initial string-buffer size. -
方法概要
修饰符和类型方法说明append(char c) Appends the specified character to this writer.append(CharSequence csq) Appends the specified character sequence to this writer.append(CharSequence csq, int start, int end) Appends a subsequence of the specified character sequence to this writer.voidclose()Closing a StringWriter has no effect.voidflush()Flush the stream.Gets the buffer.toString()Return the buffer's current value as a string.voidwrite(char[] cbuf, int off, int len) Write a portion of an array of characters.voidwrite(int c) Write a single character.voidWrite a string.voidWrite a portion of a string.从类继承的方法 java.io.Writer
nullWriter, write
-
构造器详细资料
-
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
public void write(char[] cbuf, int off, int len) Write a portion of an array of characters. -
write
Write a string. -
write
Write a portion of a string. -
append
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
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 subsequenceend- 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
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
Return the buffer's current value as a string. -
getBuffer
Gets the buffer.- 返回:
- the buffer
-
flush
public void flush()Flush the stream. -
close
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.
-