Out of memory using Scanner
The following block of code is throwing a java.lang.OutOfMemoryError
exception when I pass a large file into the scanner. What is the best way
to fix this? Is the problem in the arraylist or the scanner?
ArrayList rawData = new ArrayList();
Scanner scan = new Scanner(file);
while (scan.hasNext()) {
String next = scan.next();
rawData.add(next);
}
No comments:
Post a Comment