title: Why doesnt my code work?
body: <p>This method is supposed to load the next question into a GUI. </p>
  
  <pre><code>public void readNextEntry() {
  
      list = new ArrayList&lt;String&gt;();
  
      scanner = new Scanner(linesFromFile.get(currentQuestion)).useDelimiter(",|\n");
      for (int i = 0; i &lt; 8; i++) {
          list.add(scanner.next());
      }
  }
  </code></pre>
  
  <p>The text file it is supposed to load from is as follows in the format:</p>
  
  <pre class="lang-none prettyprint-override"><code>001,what color is the sky,it is blue because of precipitation,green,blue,yellow,red,a,   
  002,What color are my eyes,they are blue if you look,blue,brown,green,black,a,    
  003,What color is the water,it is blue because of water,green,blue,red,yellow,b,
  </code></pre>
  
  <p>Why doesn't it work? It's supposed to load in, the category (<code>001</code>), the question (<code>what color is the sky?</code>), and the choices for it (<code>green,blue,yellow,red</code>).  Is my regex off?</p>
  
  <p>edit:
  a bit of context, this is the full code. Been trying suggestions from this thread with no success thus far.</p>
  
  <pre><code>package TestAssignment;
  
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.io.*;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Scanner;
  import javax.swing.*;
  import javax.swing.border.Border;
  
  public class TestGui extends JFrame implements ActionListener {
  
  private int counter = 0;
  private int totalCount = 0;
  private JTextArea question = new JTextArea();
  private JTextArea recomendedAnswer = new JTextArea();
  private JTextArea category = new JTextArea();
  private ArrayList&lt;String&gt; list;
  private ArrayList&lt;String&gt; linesFromFile;
  private int currentQuestion = 0;
  private ButtonGroup group = new ButtonGroup();
  private ArrayList&lt;JRadioButton&gt; theButtons;
  private JLabel response = new JLabel("");
  private JButton answer = new JButton("Answer Question");
  private Border border = BorderFactory.createLineBorder(Color.BLACK, 1);
  private Scanner scanner;
  private String fileName;
  
  public void readNextEntry() {
  
      list = new ArrayList&lt;String&gt;();
  
      scanner = new Scanner(linesFromFile.get(currentQuestion)).useDelimiter(",|\n");
      for (int i = 0; i &lt; 8; i++) {
          list.add(scanner.next());
      }
  }
  
  public void readFile() {
      linesFromFile = new ArrayList&lt;String&gt;();
      list = new ArrayList&lt;String&gt;();
      try {
  
          scanner = new Scanner(new File(fileName));
          while (scanner.hasNextLine()) {
              linesFromFile.add(scanner.nextLine());
          }
          Collections.shuffle(linesFromFile);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
  }
  
  public TestGui(String in) {
  
      setLayout(new GridLayout(11, 25));
      this.fileName = in;
  
      add(new JLabel("Category : "));
      JScrollPane scrollPane1 = new JScrollPane(category);
      category.setLineWrap(true);
      category.setBorder(border);
      add(scrollPane1);
      category.setEditable(false);
  
      //int randomNumber = (int) (Math.random() * 10) + 1;
      //String line = TestGui.readFileByLine("Questions.txt", randomNumber);
  
      add(new JLabel("Question: "));
      JScrollPane scrollPane2 = new JScrollPane(question);
      question.setLineWrap(true);
      question.setBorder(border);
      add(scrollPane2);
      question.setEditable(false);
  
      readFile();
      readNextEntry();
  
      add(new JLabel("Please Select the correct Answer"));
  
      theButtons = new ArrayList&lt;JRadioButton&gt;();
  
      for (int i = 0; i &lt; 4; i++) {
          JRadioButton temp = new JRadioButton();
          theButtons.add(temp);
          add(temp);
          group.add(temp);
      }
      refreshButtonLabels();
  
      add(response);
  
      category.setText(list.get(0));
      question.setText(list.get(1));
  
      add(answer);
  
      answer.addActionListener(this);
     }
  
    public void refreshButtonLabels() {
      for (int i = 0; i &lt; 4; i++) {
          theButtons.get(i).setText(list.get(i + 3));
      }
    }
  
      @Override
      public void actionPerformed(ActionEvent e) {
      if (e.getSource() == answer) {
          for (int i = 0; i &lt; theButtons.size(); i++) {
              JRadioButton button = theButtons.get(i);
              if (button.isSelected() &amp;&amp; list.get(7).equals("a")) {
                  counter++;
                  readNextEntry();
              }
              else if (button.isSelected() &amp;&amp; list.get(7).equals("b")){
                  counter++;
                  readNextEntry();
              }
               else if (button.isSelected() &amp;&amp; list.get(7).equals("c")){
                  counter++;
                  readNextEntry();
              }
               else if (button.isSelected() &amp;&amp; list.get(7).equals("d")){
                  counter++;
                  readNextEntry();
  
              }
          }
      }
       else {
             readNextEntry();
            {
      }
      }
  
  
  
  
  
  package TestAssignment;
  
  import javax.swing.JFrame;
  
  
  public class Test {
  public static void main(String[] args) {
      TestGui test = new TestGui();
      test.setVisible(true);
      test.setSize(600, 600);
      test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  }
  }
  </code></pre>