title: adding objects to java queues from a data file
body: <p>I am trying to add objects to a queue from a data file which is made up of text which is made up of a person's first name and their 6 quiz grades (ie: Jimmy,100,100,100,100,100,100). I am accessing the data file using the FileReader and using BufferReader to read each line of my data file and then tokenize each line using the "," deliminator to divide the names and quiz grades up. Based on what I think my professor is asking for is to create a queue object for each student. The assignment says,</p>
  
  <p>Read the contents of the text file one line at a time using a loop. In this loop, invoke the processInputData method for each line read. This method returns the corresponding Student object. Add this student object to the studentQueue. </p>
  
  <p>If someone could point me the right direction that would be great! Here is my code so far:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.LinkedList;
  import java.util.StringTokenizer;
  
  public class Test {
  
  public static void main(String[] args) {
      // Create an empty queue of student objects
      LinkedList&lt;Student&gt; studentQueue;
      studentQueue = new LinkedList&lt;Student&gt;();
  
  
      // Create an empty map of Student objects
      HashMap&lt;String, Student&gt; studentMap = new HashMap&lt;String, Student&gt;();
      System.out.printf("Initial size = %d\n", studentMap.size());
  
      // Open and read text file
      String inputFileName = "data.txt";
      FileReader fileReader = null;
  
      // Create the FileReader object
      try {
          fileReader = new FileReader(inputFileName);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
      // BufferReader to read text file
      BufferedReader reader = new BufferedReader(fileReader);
      String input;
  
      // Read one line at a time until end of file
      try {
          input = reader.readLine();
          while (input != null) {
              processInputData(input);
              input = reader.readLine();
              }
          } 
      catch (IOException e) {
          e.printStackTrace();
      }
      // Close the input
      try {
          fileReader.close();
      } 
  
      catch (IOException e) {
          e.printStackTrace();
      }
  }
  
  // Tokenize the data using the "," as a delimiter
  private static void processInputData(String data) {
      StringTokenizer st = new StringTokenizer(data, ",");
      String name = st.nextToken();
      String homework1 = st.nextToken();
      String homework2 = st.nextToken();
      String homework3 = st.nextToken();
      String homework4 = st.nextToken();
      String homework5 = st.nextToken();
      String homework6 = st.nextToken();
  
      // Using the set methods to correspond to the Student object
      Student currentStudent = new Student(name);
      currentStudent.setHomework1(Integer.parseInt(homework1));
      currentStudent.setHomework2(Integer.parseInt(homework2));
      currentStudent.setHomework3(Integer.parseInt(homework3));
      currentStudent.setHomework4(Integer.parseInt(homework4));
      currentStudent.setHomework5(Integer.parseInt(homework5));
      currentStudent.setHomework6(Integer.parseInt(homework6));
      System.out.println("Input File Processing...");
      System.out.println(currentStudent);
  
  }
  } 
  </code></pre>