title: Counting numbers in a text file using Java
body: <p>This has been troubling me for a while now. I normally don't tend to ask help and do my research, but I couldn't find an answer.</p>
  
  <p>How do I write a program that reads a text file, and calculate how many times a certain number shows up?
  I'm a huge beginner in Java, and also programming in general. 
  Here's my code.</p>
  
  <p>This code generates a text file that has 100 random numbers</p>
  
  <pre><code>import java.io.*;
  
  public class Rolling 
  {
      public static void main (String[] args) throws IOException
      {
          int randomNum;
  
          PrintWriter fileout = new PrintWriter (new FileWriter ("randumnums.txt"));
  
          for (int i= 0; i &lt; 101; i++)
          {
              randomNum = (int) (Math.random() * 100);
  
              fileout.println (randomNum);
          }
          fileout.close();
      }
  }
  </code></pre>
  
  <p>Now the trouble I'm having is that I need to read the file and write a code saying X number was rolled 3 times. e.g the number 4 appeared 5 times in the text file, so I would need it to print "the number 4 was rolled 5 times". </p>
  
  <pre><code>import java.io.*;
  
  public class Reading 
  {
      public static void main (String[] args) throws IOException
      {
          BufferedReader readFile = new BufferedReader (new FileReader ("randumnums.txt"));
          int number = 0;
          int inMarks [] = new int [100]; 
  
          for (int i = 0; i &lt; 100; i++)
          {
              inMarks [i] = Integer.parseInt(readFile.readLine());
          }   
      } 
  }
  </code></pre>