Reputation: 8138
I have written a groovy script to read a huge file line by line.
I currently am using boilerplate code as follows
File hugeFile = new File(filePath)
if (hugeFile.exists()) {
hugeFile.eachLine {line ->
//some process
}
}
My question is how do I find out if the "eachLine" is using a BufferedReader to be memory efficient ?
Upvotes: 2
Views: 3333
Reputation: 14529
Give it a shot to see if it can handle big files.
And check the source at github:
public static <T> T eachLine(Reader self, int firstLine, @ClosureParams(value=FromString.class,options={"String","String,Integer"}) Closure<T> closure) throws IOException {
BufferedReader br;
int count = firstLine;
T result = null;
if (self instanceof BufferedReader)
br = (BufferedReader) self;
else
br = new BufferedReader(self);
...
}
Upvotes: 7