Java - Reading from csv file getting null value
<p>I am getting a null value when im reading from my teachers. csv file. Column 1 which is att[0] works but att[1] returns 3 null values.</p>

<p>My csv looks like this:
1, Mr Murphy
2, Mr Davis
3, Ms Simpson
Each on separate lines ie line 1 -> 1, Mr Murphy etc</p>

<p>Here is my code:</p>

<pre><code>import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ReadCSV
{
    public static void main(String[] args)
    {
        //Input file which needs to be parsed
        String readTeachers = "teacher.csv";
        BufferedReader fileReader = null;

        //Delimiter used in CSV file
        final String DELIMITER = ",";

        try
        {
            String line = "";
            //String line = inFile.readLine();
            //Create the file reader
            fileReader = new BufferedReader(new FileReader(readTeachers));
            int count=0;
            String[] att = new String[10];
            //Read the file line by line
            while ((line = fileReader.readLine()) != null) 
            {
                //Get all tokens available in line
                String[] tokens = line.split(DELIMITER);

                int i=0;

                count++;
                for(String token : tokens)
                {
                    att[i] = token;
                    i++;
                    //Print all tokens
                   // System.out.println(token);

                    System.out.println(att[1]);
                    break;
                }


            }
            //System.out.println(count);
            //System.out.println(att[1]);
        } 
        catch (Exception e) {
            e.printStackTrace();
        } 
        finally
        {
            try {
                fileReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
</code></pre>