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 Writer append(CharSequence csq)
append 在接口中 Appendableappend 在类中 Writerpublic Writer append(CharSequence csq, int start, int end)
append 在接口中 Appendableappend 在类中 Writerpublic Writer append(char c)
append 在接口中 Appendableappend 在类中 WriterCopyright © 2024. All rights reserved.