title: java.nio.charset.MalformedInputException: Input length = 1
body: <p>I have this (stripped the HTML tags for the code example) function that builds a HTML table out of a CSV, but I get a runtime error everytime I try to run it and I don't know why. Google says that maybe something with the encoding is wrong but I have no idea how to change that.</p>
  
  <p>My CSV is encoded in ANSI and contains characters like ä, Ä, Ü, Ö but I have no control over the encoding or if it will change in the future.</p>
  
  <p>The error occurs here:</p>
  
  <pre><code>Caused by: java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1
  at java.io.BufferedReader$1.hasNext(Unknown Source)
  at java.util.Iterator.forEachRemaining(Unknown Source)
  at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
  at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
  at testgui.Csv2Html.start(Csv2Html.java:121)
  </code></pre>
  
  <p>Line 121 is</p>
  
  <pre><code>lines.forEach(line -&gt; {
  </code></pre>
  
  <p>Sourcecode:</p>
  
  <pre><code>protected void start() throws Exception {
  
      Path path = Paths.get(inputFile);
  
      FileOutputStream fos = new FileOutputStream(outputFile, true);
      PrintStream ps = new PrintStream(fos);      
  
      boolean withTableHeader = (inputFile.length() != 0);
      try  {
          Stream&lt;String&gt; lines = Files.lines(path);
          lines.forEach(line -&gt; {
              try {
                  String[] columns = line.split(";");
                  for (int i=0; i&lt;columns.length; i++) {
                      columns[i] = escapeHTMLChars(columns[i]);
                  }       
                  if (withTableHeader == true &amp;&amp; firstLine == true) {
                      tableHeader(ps, columns);
                      firstLine = false;
                  } else {
                      tableRow(ps, columns);
                  }
  
  
              } catch (Exception e) {
                  e.printStackTrace();
              } finally {
  
              }
          });
  
      } finally {
          ps.close();
      }
  
  }
  </code></pre>