|
|
@@ -36,6 +36,8 @@ public class FastStringWriter extends Writer {
|
|
|
private char[] value;
|
|
|
private int len;
|
|
|
|
|
|
+ boolean inUse; // 支持 reentrant
|
|
|
+
|
|
|
private static int MAX_BUFFER_SIZE = 1024 * 512; // 1024 * 64;
|
|
|
|
|
|
public static void setMaxBufferSize(int maxBufferSize) {
|
|
|
@@ -46,8 +48,14 @@ public class FastStringWriter extends Writer {
|
|
|
MAX_BUFFER_SIZE = maxBufferSize;
|
|
|
}
|
|
|
|
|
|
+ public FastStringWriter init() {
|
|
|
+ inUse = true;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void close() /* throws IOException */ {
|
|
|
+ inUse = false;
|
|
|
len = 0;
|
|
|
|
|
|
// 释放空间占用过大的缓存
|
|
|
@@ -56,6 +64,10 @@ public class FastStringWriter extends Writer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public boolean isInUse() {
|
|
|
+ return inUse;
|
|
|
+ }
|
|
|
+
|
|
|
public String toString() {
|
|
|
return new String(value, 0, len);
|
|
|
}
|