diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java index 0a1a7ba38..b3c099adb 100644 --- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java +++ b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java @@ -114,17 +114,14 @@ public final class ChainReaderHelper { } /** - * Process the reader chain + * Assemble the reader */ - public final String processStream() - throws BuildException, IOException { - + public final Reader getAssembledReader() throws BuildException { if (primaryReader == null) { throw new BuildException("primaryReader must not be null."); } Reader instream = primaryReader; - final char[] buffer = new char[bufferSize]; final int filterReadersCount = filterChains.size(); final Vector finalFilters = new Vector(); @@ -201,11 +198,21 @@ public final class ChainReaderHelper { } } } + return instream; + } + /** + * Read data from the reader and return the + * contents as a string. + */ + public final String readFully(Reader rdr) + throws IOException { + + final char[] buffer = new char[bufferSize]; int bufferLength = 0; String text = null; while (bufferLength != -1) { - bufferLength = instream.read(buffer); + bufferLength = rdr.read(buffer); if (bufferLength != -1) { if (text == null) { text = new String(buffer, 0, bufferLength); diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java index 66f7c3b8c..7f6222440 100644 --- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java +++ b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java @@ -194,8 +194,9 @@ public final class LoadFile extends Task { crh.setBufferSize(size); crh.setPrimaryReader(instream); crh.setFilterChains(filterChains); + instream = crh.getAssembledReader(); - String text = crh.processStream(); + String text = crh.readFully(instream); if (text != null) { if(evaluateProperties) { diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java index 5e0c4a4ec..ca5b07527 100644 --- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java +++ b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java @@ -128,8 +128,9 @@ public final class LoadProperties extends Task { crh.setBufferSize(size); crh.setPrimaryReader(instream); crh.setFilterChains(filterChains); + instream = crh.getAssembledReader(); - String text = crh.processStream(); + String text = crh.readFully(instream); if (text != null) { if (!text.endsWith("\n")) {