I've implemented the following code within my Java application
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);
String xmlString = sw.toString().replaceAll("&[^;]+?;", ""); //Replace invalid HTML characters
//print xml
System.out.println("The XML is:\n\n" + xmlString);
OutputStream out = new FileOutputStream(dir.getSearchFileOutputDirectory() + "\\" + "output.xml");
//Write the XML to disk
out.write(xmlString.getBytes("ISO-8859-1"));
out.close();
Now, if I run this within Netbeans, the XML file renders perfectly within Chrome, IE and Firefox. However, once I clean and build the code, then run the standalone JAR file, the browsers report encoding errors within the file, and fails to render it.
The thing is the lines they are failing at don't really contain anything out of the ordinary, just standard ASCII characters that I can see.
Can anyone shed light on why this might be happening? I've got to demo the code tomorrow and now I'm getting in a panic as to why its suddenly doing this strange thing...
Any input would be greatly appreciated.
Thanks
Tony