Java Csv-data String space split error
<p>I am having some trouble with a command.</p>

<p>I have a file of the type csv which looks like this:</p>

<p>Merkmals-Nr.;Interne Teile-Nr.;Bereich;Fertigungsschritt;...</p>

<p>After reading the File in is want to read one Line and then split the line after ";" by using this codeline.</p>

<pre><code>List&lt;String&gt; datenListe = Arrays.asList(data.split(";"));
</code></pre>

<p>Then I do a system.println</p>

<p>How the print should look:<br>
    Merkmals-Nr.<br>
    Interne Teile-Nr.<br>
    Bereich<br>
    Fertigungsschritt<br>
    ...  </p>

<p>How the print actually looks:<br>
    Merkmals-Nr.<br>
    Interne</p>

<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
    at java.util.Arrays$ArrayList.get(Arrays.java:2866)
    at CsvEinlesen.main(CsvEinlesen.java:23)
</code></pre>

<p>I figured out that the problem is caused by the space in "Interne Teile-Nr." but I don´t know how to solve the problem with the spaces.</p>

<p>This is thecomplete code:</p>

<pre><code>import java.io.*;

import java.util.*;


public class CsvEinlesen {
  public static void main(String[] args) {
    String fileName = "0-201-08-4473.csv";
    File file = new File(fileName);

    try {
      Scanner csvInputStream = new Scanner(file);

      while (csvInputStream.hasNext()) {
        String data = csvInputStream.next();

        List&lt;String&gt; datenListe = Arrays.asList(data.split(";"));

        for (int i = 0; i &lt; 32; i++) {
          System.out.println(datenListe.get(i));
        }
      }

      csvInputStream.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      System.out.println("CSV-Datei nicht gefunden");
    }
  }
}
</code></pre>