I need to transform file from ISO-8859-2 charset to UTF-8.
My code is:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);
DOMSource domSource = new DOMSource(doc);
String fileName2 = UUID.randomUUID().toString() + "222";
Writer out = new OutputStreamWriter(new FileOutputStream("/Users/user/Kohana/" + fileName2 + ".xml"), "UTF8");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.transform(domSource, new StreamResult(out));
But the problem is, that after transform, the file is still ISO-8859-2.
What am i doing wrong ?