public class FastStringWriter extends Writer
由 JDK 中 Writer 改造而来,在其基础之上做了如下改变: 1:添加 char[] value 直接保存 char 值 2:添加 int len 记录数据长度 3:去掉 synchronized 操作 4:添加 MAX_BUFFER_SIZE,限定 value 被重用的最大长度 5:去掉了 close() 方法声明中的 throws IOException,并添加缓存回收逻辑
| 构造器和说明 |
|---|
FastStringWriter() |
FastStringWriter(int capacity) |
| 限定符和类型 | 方法和说明 |
|---|---|
Writer |
append(char c) |
Writer |
append(CharSequence csq) |
Writer |
append(CharSequence csq,
int start,
int end) |
void |
close() |
protected void |
expandCapacity(int newLen)
扩容
|
void |
flush() |
FastStringWriter |
init() |
boolean |
isInUse() |
static void |
setMaxBufferSize(int maxBufferSize) |
String |
toString() |
StringBuilder |
toStringBuilder() |
void |
write(char[] buffer) |
void |
write(char[] buffer,
int offset,
int len) |
void |
write(int c) |
void |
write(String str) |
void |
write(String str,
int offset,
int len) |
public FastStringWriter(int capacity)
public FastStringWriter()
public static void setMaxBufferSize(int maxBufferSize)
public FastStringWriter init()
public void close()
public boolean isInUse()
public StringBuilder toStringBuilder()
protected void expandCapacity(int newLen)
public void write(char[] buffer,
int offset,
int len)
throws IOException
write 在类中 WriterIOExceptionpublic void write(String str, int offset, int len) throws IOException
write 在类中 WriterIOExceptionpublic void write(int c)
throws IOException
write 在类中 WriterIOExceptionpublic void write(char[] buffer)
throws IOException
write 在类中 WriterIOExceptionpublic void write(String str) throws IOException
write 在类中 WriterIOExceptionpublic Writer append(CharSequence csq) throws IOException
append 在接口中 Appendableappend 在类中 WriterIOExceptionpublic Writer append(CharSequence csq, int start, int end) throws IOException
append 在接口中 Appendableappend 在类中 WriterIOExceptionpublic Writer append(char c) throws IOException
append 在接口中 Appendableappend 在类中 WriterIOExceptionpublic void flush()
throws IOException
flush 在接口中 Flushableflush 在类中 WriterIOExceptionCopyright © 2024. All rights reserved.