Browse Source

When passed through filters, the resulting size of the filtered data may be

larger than the actual file size.  Keep reading till -1 is returned.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271379 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 23 years ago
parent
commit
ef148d08a2
1 changed files with 12 additions and 5 deletions
  1. +12
    -5
      proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java

+ 12
- 5
proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java View File

@@ -183,9 +183,6 @@ public final class LoadFile extends Task {
final long len = srcFile.length();
log("file size = "+len,Project.MSG_DEBUG);
//discard most of really big files
if (len > Integer.MAX_VALUE) {
log("this file is far to big to load completely");
}
final int size=(int) len;
//open up the file
fis = new FileInputStream(srcFile);
@@ -290,8 +287,18 @@ public final class LoadFile extends Task {
}
}

final int bufferLength = instream.read(buffer);
final String text = new String(buffer, 0, bufferLength);
int bufferLength = 0;
String text = null;
while (bufferLength != -1) {
bufferLength = instream.read(buffer);
if (bufferLength != -1) {
if (text == null) {
text = new String(buffer, 0, bufferLength);
} else {
text += new String(buffer, 0, bufferLength);
}
}
}
return text;
}



Loading…
Cancel
Save