Skip to content

Commit

Permalink
Close the RandomAccessFile instance to prevent IO Exceptions.
Browse files Browse the repository at this point in the history
large numbers of files being scanned would yield
Exception in thread "main" java.io.FileNotFoundException: <redacted> (Too many open files)
	at java.io.RandomAccessFile.open(Native Method)
	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)
	at silly.metrics.KeywordCounter.recurse(KeywordCounter.java:222)
	at silly.metrics.KeywordCounter.recurse(KeywordCounter.java:218)
	at silly.metrics.KeywordCounter.recurse(KeywordCounter.java:218)
  • Loading branch information
jwadamson committed Sep 17, 2014
1 parent d1f16af commit eb67c8a
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -222,6 +222,7 @@ else if (file.getName().endsWith(".java")) {
RandomAccessFile f = new RandomAccessFile(file, "r");
byte[] contents = new byte[(int) f.length()];
f.readFully(contents);
f.close();
String content = new String(contents);

char c;
Expand Down

0 comments on commit eb67c8a

Please sign in to comment.