Hello everyone.
I am creating a
Java Servlet which reads a file (using a BufferedReader). Now, when I've read this file, I want to process it (search for a
String pattern.) This is not really the problem.
The problem is that the reading of the file (around 50MB) takes a very long time (on slow machines, around 15 seconds..). Therefore I want to read it only once (e.g. in init() ), and put it in memory (application scope) after that. Now I tried using the readLine() methode to put the file in a Hashtable, or in a Vector, but both fail because of an 'Out of Memory' error. When I use a small file, there's no problem, and everything works extremely fast. Usually the error occurs after processing 68000 lines of text...that's not even halfway the actual file.
Does anyone got an idea on how to solve this problem? Any help would be greatly appriciated!
Thanks,
Erik