Rank Pages in a Directory by Occurrence of a Particular Word in them – Java Data Mining

This is an example of Data Mining with the help of Java.

We’re calculating the number of occurrences of a specified word in all the files in a specified folder, and then ranking them accordingly.

  • We’ve used the class FileInputStream to stream the data from a file and the class StringBuffer to buffer the streaming bytes from the file and form 1 long string out of it.
  • Class File for getting all files in a folder and enlisting them in an array
  • Variable iCh is an Integer variable and will store the ASCII value for the current character.
  • Make sure to provide the full path to whichever folder you want to access.(Eg. C:\Mining)
  • Only use files and folders which you’re sure you have access to


  • Debug using Command Prompt/Eclipse/whichever compiler as an administrator to get over Access Denied exceptions.
  • Use method equalsIgnoreCase(word) instead of equals(word) to make it work case-insensitive.
The following two tabs change content below.

Lalit Mali

Lalit is a technology enthusiast, a programming lover and currently an Android fan.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">