Moderator: robert
TextEditorPane textArea = new TextEditorPane();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
FileLocation file = new FileLocation("C:/temp/test.java");
// null second parameter => use system encoding, if no BOM is found.
// Otherwise this parameter should be the encoding to load with if no BOM.
textArea.load(file, null);
textArea.setEncoding("UTF-8");
textArea.save();
try {
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("C:/my/file.txt"), "UTF-8"));
textArea.write(w);
w.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
// Tell UnicodeWriter to always write BOMs.
System.setProperty(UnicodeWriter.PROPERTY_WRITE_UTF8_BOM, "true");
BufferedWriter bw = new BufferedWriter(new UnicodeWriter("C:\\test.txt", "UTF-8"));
bw.write("sandeep");
bw.close();
Users browsing this forum: No registered users and 1 guest