title: Calling a method with BufferedReader
body: <p>So i have this method to read a file in my main class, and it works perfectly fine</p>
  
  <pre><code>reader = new BufferedReader(new FileReader("how.txt"));
      List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
      String line = reader.readLine();
      while( line != null ){
          lines.add(line);
          line = reader.readLine();
      }
      //Choose a random one from the list
      Random r = new Random();
      String randString=lines.get(r.nextInt(lines.size()));
      System.out.println(randString);
  </code></pre>
  
  <p>Now, the problem is, i need to use this method multiple times in the main class, and i want to create a class for this method so that i don't have to copy and paste the whole method for different files that i want to read. I have attempted to create the class:</p>
  
  <pre><code>public class reader {
  
  public static String readfile (String file) throws IOException{
      BufferedReader reader = new BufferedReader(new FileReader("file"));
      List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
      String line = reader.readLine();
      while( line != null ){
          lines.add(line);
          line = reader.readLine();
      }
      //Choose a random one from the list
      Random r = new Random();
      String randString=lines.get(r.nextInt(lines.size()));
      System.out.println(randString);
  
      return file;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But when i call the method in the main class like this:</p>
  
  <pre><code>String randString = reader.readfile("file.txt");
  </code></pre>
  
  <p>it gives me an error saying that the method "reafile(String)" is undefined for the type BufferedReader.</p>
  
  <p>So how do I fix this? Or how do you create the method in a different class and call it in the main class?
  Thanks :)</p>