title: Ensure Unix-style line endings used when generating XML on Windows with Java
body: <p>I am currently outputting an XML document to a file in Java as follows:</p>
  
  <pre><code>final Document xmldoc = toXMLDocument(docTheory);
  
  // write the content into xml file
  TransformerFactory transformerFactory = TransformerFactory.newInstance();
  Transformer transformer = transformerFactory.newTransformer();
  transformer.setOutputProperty(OutputKeys.INDENT, "yes");
  transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
  DOMSource source = new DOMSource(xmldoc);
  StreamResult result = new StreamResult(file);
  
  transformer.transform(source, result);
  </code></pre>
  
  <p>However, when run on Windows, this produces output with Windows-style line-endings.  I would like to have Unix-style line endings produced regardless of OS.  How I can do this?</p>