浏览代码

支持 reentrant

James 5 年之前
父节点
当前提交
8daabf0aff
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      src/main/java/com/jfinal/template/io/CharWriter.java

+ 12 - 4
src/main/java/com/jfinal/template/io/CharWriter.java

@@ -26,23 +26,31 @@ public class CharWriter extends Writer {
 	java.io.Writer out;
 	char[] chars;
 	
+	boolean inUse;	// 支持 reentrant
+	
 	public CharWriter(int bufferSize) {
 		this.chars = new char[bufferSize];
 	}
 	
 	public CharWriter init(java.io.Writer writer) {
+		inUse = true;
 		this.out = writer;
 		return this;
 	}
 	
-	public void flush() throws IOException {
-		out.flush();
-	}
-	
 	public void close() {
+		inUse = false;
 		out = null;
 	}
 	
+	public boolean isInUse() {
+		return inUse;
+	}
+	
+	public void flush() throws IOException {
+		out.flush();
+	}
+	
 	public void write(String str, int offset, int len) throws IOException {
 		int size;
 		while (len > 0) {