On Tuesday 23 September 2003 11:10, [EMAIL PROTECTED] wrote:
> I have tried with closing them, but it doesn´t work.
> But send me your code please. Maybe you have done some different :-)
>
>
Attached.
Peter
Index: ConcatFilter.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/filters/ConcatFilter.java,v
retrieving revision 1.2
diff -u -r1.2 ConcatFilter.java
--- ConcatFilter.java 19 Sep 2003 09:24:13 -0000 1.2
+++ ConcatFilter.java 23 Sep 2003 10:12:46 -0000
@@ -89,10 +89,10 @@
private File append;
/** Reader for prepend-file. */
- private Reader prependReader = new EmptyReader();
+ private Reader prependReader = null;
/** Reader for append-file. */
- private Reader appendReader = new EmptyReader();
+ private Reader appendReader = null;
/**
* Constructor for "dummy" instances.
@@ -136,12 +136,24 @@
// The readers return -1 if they end. So simply read the "prepend"
// after that the "content" and at the end the "append" file.
- ch = prependReader.read();
+ if (prependReader != null) {
+ ch = prependReader.read();
+ if (ch == -1) {
+ prependReader.close();
+ prependReader = null;
+ }
+ }
if (ch == -1) {
ch = super.read();
}
if (ch == -1) {
- ch = appendReader.read();
+ if (appendReader != null) {
+ ch = appendReader.read();
+ if (ch == -1) {
+ appendReader.close();
+ appendReader = null;
+ }
+ }
}
return ch;
@@ -234,13 +246,4 @@
}
}
- /**
- * Reader which is always at the end of file.
- * Used for easier algorithm (polymorphism instead if-cascades).
- */
- private class EmptyReader extends Reader {
- public int read(char[] ch, int i1, int i2) { return -1; }
- public void close() { }
- }
-
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]