title: All inclusive Charset to avoid "java.nio.charset.MalformedInputException: Input length = 1"?
body: <p>I'm creating a simple wordcount program in Java that reads through a directory's text-based files.</p>
  
  <p>However, I keep on getting the error:</p>
  
  <pre><code>java.nio.charset.MalformedInputException: Input length = 1
  </code></pre>
  
  <p>from this line of code:</p>
  
  <pre><code>BufferedReader reader = Files.newBufferedReader(file,Charset.forName("UTF-8"));
  </code></pre>
  
  <p>I know I probably get this because I used a <code>Charset</code> that didn't include some of the characters in the text files, some of which included characters of other languages. But I want to include those characters.</p>
  
  <p>I later learned at the <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newBufferedReader-java.nio.file.Path-">JavaDocs</a> that the <code>Charset</code> is optional and only used for a more efficient reading of the files, so I changed the code to:</p>
  
  <pre><code>BufferedReader reader = Files.newBufferedReader(file);
  </code></pre>
  
  <p>But some files still throw the <code>MalformedInputException</code>. I don't know why.</p>
  
  <p><strong>I was wondering if there is an all-inclusive <code>Charset</code> that will allow me to read text files with many different types of characters</strong>?</p>
  
  <p>Thanks.</p>