How can I separate a single String into two parts?
<p>I have a text document that consists of a number of lines, each of which has a username, a comma, and a password. For example,</p>

<pre><code>Joe, pass1
Sally, badpassword
Ahmed, goodpassword
</code></pre>

<p>And so forth.</p>

<p>I can read those lines into my program without any trouble. After that I want to separate them into an <code>ArrayList</code>. <code>String.split()</code> says it should separate them into an array. I need an <code>ArrayList</code>, and anyway the when I invoke <code>split()</code> my <code>String</code> is unchanged. So I don't know how to proceed.</p>

<p>This is where I think I am having a problem:</p>

<pre><code>                while (true) {
                    if ((str = br1.readLine()) != null)
                        break;
                    out.println(str);
                    str.split(",");
                    userstr.add(str);
                }     
</code></pre>

<p>This is the whole class:</p>

<pre><code>public BuggerGUI() {
    super("password");
    setLayout(new GridLayout(3, 4));
    userL = new JLabel("username");
    add(userL);
    userT = new JTextField(10);
    add(userT);
    passL = new JLabel("password: ");
    add(passL);
    passT = new JPasswordField(10);
    add(passT);
    blankL = new JLabel();
    add(blankL);
    loggin =  new JButton("login");
    add(loggin);
    handler Handler = new handler();
    userT.addActionListener(Handler);
    passT.addActionListener(Handler);
    loggin.addActionListener(Handler);
}

private class handler implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent event) {
        String user = userT.getText();
        String pass = passT.getText();
        if (event.getSource() == loggin) {
            out.println("username: " + user);
            out.println("password: " + pass);
            try {
                ArrayList userstr = new ArrayList();
                FileReader fr1 = new FileReader("C:\\Users\\Owner\\Desktop\\passlist.txt");
                BufferedReader br1 = new BufferedReader(fr1);
                String str;
                while (true) {
                    if ((str = br1.readLine()) != null)
                        break;
                    out.println(str);
                    str.split(",");
                    userstr.add(str);
                }     
                for (int i = 0; i &lt; userstr.size();)
                    if (userT.equals(userstr.get(i)))
                        out.print("cool");   
            } catch(IOException e) {
                System.out.println(ERROR);
            }
        }
    }
}
</code></pre>