Browse Source

支持 reentrant

James 5 years ago
parent
commit
8daabf0aff
1 changed files with 12 additions and 4 deletions
  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;
 	java.io.Writer out;
 	char[] chars;
 	char[] chars;
 	
 	
+	boolean inUse;	// 支持 reentrant
+	
 	public CharWriter(int bufferSize) {
 	public CharWriter(int bufferSize) {
 		this.chars = new char[bufferSize];
 		this.chars = new char[bufferSize];
 	}
 	}
 	
 	
 	public CharWriter init(java.io.Writer writer) {
 	public CharWriter init(java.io.Writer writer) {
+		inUse = true;
 		this.out = writer;
 		this.out = writer;
 		return this;
 		return this;
 	}
 	}
 	
 	
-	public void flush() throws IOException {
-		out.flush();
-	}
-	
 	public void close() {
 	public void close() {
+		inUse = false;
 		out = null;
 		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 {
 	public void write(String str, int offset, int len) throws IOException {
 		int size;
 		int size;
 		while (len > 0) {
 		while (len > 0) {