troubleshooting Question

search a pattern in a large file using java

Avatar of pvinodp
pvinodp asked on
JavaSearch Engine Optimization (SEO)
20 Comments1 Solution650 ViewsLast Modified:
Following is my code in a particular function.
     Scanner sc = new Scanner(new File("/exports/nos_issues/9518/aaa_.log"));
      String str="10:37:10.719 [net.jradius.freeradius.FreeRadiusProcessor(29)] DEBUG net.jradius.log.Log4JRadiusLogger - >>> packets";
      Pattern ptr = Pattern.compile(str);
      long toto=0;
         while(sc.findWithinHorizon(ptr ,0000) != null)

I get the following error :

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      at java.nio.HeapCharBuffer.<init>(
      at java.nio.CharBuffer.allocate(
      at java.util.Scanner.makeSpace(
      at java.util.Scanner.readInput(
      at java.util.Scanner.findWithinHorizon(
      at Cl.main(

in the class Cl the line number 38 points to sc.close();
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 20 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros