title: How can I specify encoding when parsing text with Apache TIKA?
body: <p>The question is pretty self-explanatory. </p>
  
  <p>The problem I am facing is that any Tika example code I found online is using a StringWriter, as shown below. If i could somehow make this use an OutputStreamWriter, I can specify the encoding no problem... Any help would be appreciated.</p>
  
  <pre><code>InputStream inStream = new FileInputStream(pathname);
  StringWriter sw = new StringWriter();
  SAXTransformerFactory factory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
  TransformerHandler handler = factory.newTransformerHandler();
  handler.getTransformer().setOutputProperty(OutputKeys.METHOD,"html");
  handler.getTransformer().setOutputProperty(OutputKeys.INDENT,"no");
  handler.setResult(new StreamResult(sw));
  parser.parse(inStream, handler, metadata, context);
  </code></pre>