Setting the encoding on an inputstream
<p>I'm processing xml in Java and I have the following code:</p>

<pre><code>  dbf.setValidating(false);
  dbf.setIgnoringComments(false);
  dbf.setIgnoringElementContentWhitespace(true);
  dbf.setNamespaceAware(true);

  DocumentBuilder db = null;
  db = dbf.newDocumentBuilder();
  db.setEntityResolver(new NullResolver());
  _logger.error("Before processing the input stream");
  processXml(db.parse(is));
</code></pre>

<p>Where (is) is an InputStream.</p>

<p>This is resulting in the error:</p>

<blockquote>
  <p>com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:
  Invalid byte 2 of 2-byte UTF-8</p>
</blockquote>

<p>Which sounds like an error resulting from getting the wrong encoding. I would like to set the encoding on the InputStream but I am not sure how. I found ways to set the encoding on an InputSource or an InputStreamReader but then the db.parse does not take a reader/InputSource.</p>

<p>What is the best way to fix this?</p>

<p>Thanks!</p>
