title: string splitted by comma in java csv file
body: <p>It seems to be very easy problem to solve but I've stuck on it. Anybody can help me and explain where I do a mistake ?
  I read a csv file where I have:</p>
  
  <pre><code>Time,Activ,Switch,A,B,C,D,E
  5:58,on,,,,,,
  6:00,on 123,,,ab cd,,,
  6:02,on - off,1-&gt;2,6,ab cd,1,,
  6:04,on,,,cd ab,1,,
  6:06,off,,,,,,
  7:22,on / off,,,,,,
  7:30,on / of,3-&gt;4,15,,,,
  7:34,home on,,,ab cd,,,
  </code></pre>
  
  <p>I would like to separate data in a row only by the commas and save into arrays that will look like (first row omitted):</p>
  
  <pre><code>1---&gt; ["5:58","on", "", "", "", "", "", ""]
  2---&gt; ["6:00", "on 123", "", "", "ab cd", "", "", ""]
  3---&gt; ["6:02", "on - off", "1-&gt;2", "6", "ab cd", "1", "", ""]
  6---&gt; ["7:22", "on / off", "3-&gt;4", "15", "", "", "", ""]
  </code></pre>
  
  <p>and so on... but I receive arrays with splitted string also by space and other characters</p>
  
  <pre><code>1---&gt; ["5:58","on", "", "", "", "", "", ""]
  2---&gt; ["6:00", "on", "123", "", "", "ab", "cd", "", "", ""]
  3---&gt; ["6:02", "on", "-", "off", "1-&gt;2", "6", "ab", "cd", "1", "", ""]
  6---&gt; ["7:22", "on", "/", "off", "3-&gt;4", "15", "", "", "", ""]
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>public class Test {
      public static void main(String []args) {
  
      String fileName = "TestData.csv";
      File file = new File(fileName);
  
      try{
          Scanner inputStream = new Scanner(file);
          String firstLine = inputStream.next();
              while(inputStream.hasNext()){
                  String dataRow = inputStream.next();
  
                  String[] valuesInDataRow = dataRow.split(",",-1);
  
                  for(int i=0;i&lt;valuesInDataRow.length;i++){
                      System.out.println("---&gt; " + valuesInDataRow[i]);
                  }
  
              }
              inputStream.close();
          }
          catch(FileNotFoundException e) {
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>I would be very grateful for any explanations :) </p>