forked from jasder/antlr
Resize ANTLRInputStream.data after reading a file with fewer characters than bytes
This commit is contained in:
parent
eeda06b698
commit
9d11817667
|
@ -33,6 +33,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
|
||||
/** This is an ANTLRInputStream that is loaded from a file
|
||||
* all at once when you construct the object. This is a special case
|
||||
|
@ -69,7 +70,10 @@ public class ANTLRFileStream extends ANTLRInputStream {
|
|||
}
|
||||
try {
|
||||
data = new char[size];
|
||||
super.n = isr.read(data);
|
||||
n = isr.read(data);
|
||||
if (n < data.length) {
|
||||
data = Arrays.copyOf(data, n);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
isr.close();
|
||||
|
|
Loading…
Reference in New Issue