title: Implementing file reading and Classes with arrays
body: <p>I'm here today because I need help with some code for my intro to Java course that I'm in right now.</p>
  
  <p>Basically I have to read a .txt file and set each line in the <code>.txt</code> file to a new Class object called <code>Student</code> which simply has a name and a score for a quiz or test or whatever. Basically the <code>.txt</code> file is as follows:</p>
  
  <pre><code>James 78
  Jerry 90
  Henry 95
  Juice 63
  Alex 88
  Nick 83
  </code></pre>
  
  <p>I know how to read the file but don't know how to go about creating a new student for each line within the text file. Once that's completed I have to use the Getters and Setters within my <code>Student</code> class to get the score values of each student and put them into an array so I can implement the array into my <code>Lab7</code> Method that Bubble sorts the array.</p>
  
  <p>My code is as follows:</p>
  
  <p>My <code>Student</code> Class:</p>
  
  <pre><code>public class Student {
      private String name;
      private int score;
  
      public Student(String name, int score){
          this.name = name;
          this.score = score;
      }
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public int getScore() {
          return score;
      }
  
      public void setScore(int score) {
          this.score = score;
      }
  
  }
  </code></pre>
  
  <p>And my main which is where I need the help:</p>
  
  <pre><code>import java.io.*;
  import java.util.Arrays;
  
  public class Lab7 {
  
  public static void main(String[] args) {
  
      //fileName differs per location of the file
      String fileName = "/Users/Gerard/Desktop/scores.txt";
  
      String line = null;
  
      try {
          FileReader fileReader = new FileReader(fileName);
  
          BufferedReader bufferedReader = new BufferedReader(fileReader);
  
          while((line = bufferedReader.readLine()) != null){
              System.out.println(line);
          }   
          bufferedReader.close();         
      }
      catch(FileNotFoundException ex){
          System.out.println("Unable to open file '" + fileName + "'");                
      }
      catch(IOException ex){
          System.out.println("Error reading file '" + fileName + "'");                  
  
      }
  }
  
  //Code that Gets Value of scores using getters and setters from student class 
  //and stores them into an array to be used for Lab7 which bubble sorts the array.
  
  
  public int[] Lab7(int[] arr){
      int val;
      for(int i = 0; i &lt; arr.length-1;i++){
          for(int j = 0; j &lt; arr.length-1;j++){
              if(arr[j-i] &gt; arr[j]){
                  val = arr[j-1];
                  arr[j-1] = arr[j];
                  arr[j] = val;   
              }
          }
          System.out.println("Run "+ (i+1) + Arrays.toString(arr));
          }
      }
  }
  </code></pre>