title: Skip first line while reading CSV file in Java
body: <p>I am writing a parser code to read a .csv file and parse it to XML. This is the code I have and it works, except I would like it to skip the first line in the file. So I decided to set up a HashMap but it doesn't seem to work:</p>
  <pre><code>for (int i = 0; i &lt; listOfFiles.length; i++) {
          File file = listOfFiles[i];
          if (file.isFile() &amp;&amp; file.getName().endsWith(&quot;.csv&quot;)){
          
              System.out.println(&quot;File Found: &quot; + file.getName());//Prints the name of the csv file found
  
              String filePath = sourcepath + &quot;\\&quot; + file.getName();
  
              BufferedReader br = new BufferedReader(new FileReader(file));  
  
  
  String line;
  int n = 1;
  Map&lt;Integer,String&gt; lineMap = new HashMap&lt;Integer,String&gt;();
  int k=2;
  while ((line = br.readLine()) != null) {
      System.out.println(n + &quot; iteration(s) of 1st While Loop&quot;);
      
                      lineMap.put(k, line);
  
      fw.write(&quot;          &lt;ASSET action=\&quot;AddChange\&quot;&gt;\n&quot;);
      fw.write(&quot;              &lt;HOSTNAME&gt;\n&quot;);
      hostName=line.substring(0, line.indexOf(&quot;,&quot;));
      fw.append(hostName);
      fw.write(&quot;&lt;/HOSTNAME&gt;\n&quot;);
      fw.write(&quot;              &lt;HOSTID&gt;\n&quot;);
      hostID=line.substring(line.indexOf(&quot;,&quot;)+1, nthOccurrence(line, ',', 1));
      fw.append(hostID);
      fw.write(&quot;&lt;/HOSTID&gt;\n&quot;);
      fw.write(&quot;              &lt;MACMODEL&gt;\n&quot;);
      machineModel=line.substring(nthOccurrence(line, ',', 1)+1, nthOccurrence(line, ',', 2));
      fw.append(machineModel);
      fw.write(&quot;&lt;/MACMODEL&gt;\n&quot;);
      fw.write(&quot;              &lt;PROMODEL&gt;\n&quot;);
      processorModel=line.substring(nthOccurrence(line, ',', 2)+1, nthOccurrence(line, ',', 3));
      fw.append(processorModel);
      fw.write(&quot;&lt;/PROMODEL&gt;\n&quot;);
      fw.write(&quot;              &lt;CORE&gt;\n&quot;);
      core=line.substring(nthOccurrence(line, ',', 3)+1, nthOccurrence(line, ',', 4));
      fw.append(core);
      fw.write(&quot;&lt;/CORE&gt;\n&quot;);
      fw.write(&quot;              &lt;PROC&gt;\n&quot;);
      proc=line.substring(nthOccurrence(line, ',', 4)+1, nthOccurrence(line, ',', 5));
      fw.append(proc);
      fw.write(&quot;&lt;/PROC&gt;\n&quot;);
      fw.write(&quot;              &lt;TIER&gt;\n&quot;);
      tier=line.substring(nthOccurrence(line, ',', 5)+1, nthOccurrence(line, ',', 6));
      fw.append(tier);
      fw.write(&quot;&lt;/TIER&gt;\n&quot;);
      fw.write(&quot;              &lt;PRODNAME&gt;\n&quot;);
      productName=line.substring(nthOccurrence(line, ',', 6)+1, nthOccurrence(line, ',', 7));
      fw.append(productName);
      fw.write(&quot;&lt;/PRODNAME&gt;\n&quot;);
      fw.write(&quot;              &lt;VERSION&gt;\n&quot;);
      version=line.substring(nthOccurrence(line, ',', 7)+1, nthOccurrence(line, ',', 8));
      fw.append(version);
      fw.write(&quot;&lt;/VERSION&gt;\n&quot;);
      fw.write(&quot;              &lt;SCRIPTDATA&gt;\n&quot;);
      scriptData=line.substring(nthOccurrence(line, ',', 8)+1, line.length());
      fw.append(scriptData);
      fw.write(&quot;&lt;/SCRIPTDATA&gt;\n&quot;);
      
  
    fw.write(&quot;            &lt;/ASSET&gt;\n&quot;);
    k++;
  }n++;
  </code></pre>
  <p>This is a snippet of the main part of the code. Any Ideas or Solutions???</p>