 <p>Here, I copy pasted the string shared in the question and tried</p> <pre><code>public class Test { public static void main (String...a) throws Exception { String s = "Il più crudele dei giorni"; Charset c = Charset.forName("UTF-16BE"); ByteBuffer b = c.encode(s); for (int i = 0; b.hasRemaining(); i++) { int charValue = (b.get()) &amp; 0xff; System.out.print((char) charValue); } } } </code></pre> <p>This prints the <code>s</code> as it is on the console. I assume that you already have part of code which writes to a file. You can try integrating the above code if it works for you.</p>