Class StringWriter
- All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, Appendable, AutoCloseable
-
Field Summary
Fields inherited from class java.io.Writer
lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Appends the specified character.append(CharSequence csq) Appends the character sequencecsq.append(CharSequence csq, int start, int end) Appends a subsequence ofcsq.voidclose()voidflush()toString()Returns a string representation of the object.voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoid
-
Constructor Details
-
StringWriter
public StringWriter() -
StringWriter
public StringWriter(int initialSize)
-
-
Method Details
-
close
public void close() throws java.io.IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Writer- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classjava.io.Writer- Throws:
java.io.IOException
-
write
public void write(char[] cbuf, int off, int len) throws java.io.IOException - Specified by:
writein classjava.io.Writer- Throws:
java.io.IOException
-
write
- Overrides:
writein classjava.io.Writer- Throws:
java.io.IOException
-
write
public void write(int c) throws java.io.IOException - Overrides:
writein classjava.io.Writer- Throws:
java.io.IOException
-
write
- Overrides:
writein classjava.io.Writer- Throws:
java.io.IOException
-
write
public void write(char[] cbuf) throws java.io.IOException - Overrides:
writein classjava.io.Writer- Throws:
java.io.IOException
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode()) -
getBuffer
-
append
Description copied from interface:AppendableAppends the specified character.
Parameters
c: the character to append.
Returns
this
Appendable.Throws
IOException: if an I/O error occurs.
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classjava.io.Writer
-
append
Description copied from interface:AppendableAppends the character sequence
csq. Implementation classes may not append the whole sequence, for example if the target is a buffer with limited size.If
csqisnull, the characters "null" are appended.Parameters
csq: the character sequence to append.
Returns
this
Appendable.Throws
IOException: if an I/O error occurs.
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classjava.io.Writer
-
append
Description copied from interface:AppendableAppends a subsequence of
csq.If
csqis notnullthen calling this method is equivalent to callingappend(csq.subSequence(start, end)).If
csqisnull, the characters "null" are appended.Parameters
-
csq: the character sequence to append. -
start: @param start the first index of the subsequence ofcsqthat is appended. -
end: @param end the last index of the subsequence ofcsqthat is appended.
Returns
this
Appendable.Throws
-
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifstart endorendis greater than the length ofcsq. -
IOException: if an I/O error occurs.
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classjava.io.Writer
-
-