Question: ```
public void GrabData() throws IOException
{
    try {
        BufferedReader br = new BufferedReader(new FileReader("data/500.txt"));
        String line = "";
        int lineCounter = 0;
        int TokenCounter = 1;
        arrayList = new ArrayList < String > ();

        while ((line = br.readLine()) != null) {

            //lineCounter++;
            StringTokenizer tk = new StringTokenizer(line, ",");

            System.out.println(line);

            while (tk.hasMoreTokens()) {
                arrayList.add(tk.nextToken());
                System.out.println("check");
                TokenCounter++;

                if (TokenCounter > 12) {
                    er = new DataRecord(arrayList);
                    DR.add(er);
                    arrayList.clear();
                    System.out.println("check2");

                    TokenCounter = 1;
                }

            }
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Driver.class.getName()).log(Level.SEVERE, null, ex);
    }
}

```

Hello , I am using a tokenizer to read the contents of a line and store it into an araylist. Here the GrabData class does that job. 

The only problem is that the company name ( which is the third column in every line ) is in quotes and has a comma in it. I have included one line for your example. The tokenizer depends on the comma to separate the line into different tokens. But the company name throws it off i guess. If it weren't for the comma in the company column , everything goes as normal.

Example:-
Essie,Vaill,"Litronic , Industries",14225 Hancock Dr,Anchorage,Anchorage,AK,99515,907-345-0962,907-345-1215,essie@vaill.com,http://www.essievaill.com

Any ideas?

Answer: 
First of all StringTokenizer is considered to be legacy code. From Java doc: 

> 
> StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead. 
> 
> 
> 

Using the split() method you get an array of strings. While iterating through the array you can check if the current string starts with a quote and if that's the case check if the next one ends with a quote. If you meet these 2 conditions then you know you didn't split where you wanted and you can merge these 2 together, process it like you want and continue iterating through the array normally after that. In that pass you will probably do i+=2 instead of your regular i++ and it should go unnoticed.
As you can see, in the class description, the use of [StringTokenizer](http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html) is discouraged by Oracle.
Instead of using tokenizer I would use the String [split()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split%28java.lang.String%29) method
which you can use a regular expression as argument and significantly reduce your code.

```
    String str = "Essie,Vaill,\"Litronic , Industries\",14225 Hancock Dr,Anchorage,Anchorage,AK,99515,907-345-0962,907-345-1215,essie@vaill.com,http://www.essievaill.com";
    String[] strs = str.split("(?<! ),(?! )");
    List<String> list = new ArrayList<String>(strs.length);

    for(int i = 0; i < strs.length; i++) list.add(strs[i]);

```

Just pay attention to your regex, using this one you're assuming that the comma will be always between spaces.