以下はLinuxマシンでは機能しません。
Charset charset = Charset.forName("UTF-8");
CharsetDecoder decoder = charset.newDecoder();
try {
FileOutputStream fo = new FileOutputStream("hi.txt");
PrintStream ps = new PrintStream(fo);
String msgBody = "ΣYMMETOXH";
ps.println(decoder.decode(ByteBuffer.wrap(decoder.decode(ByteBuffer.wrap(msgBody.getBytes())).toString().getBytes())));
ps.close();
fo.close();
} catch (CharacterCodingException e) {
e.printStackTrace();
}
このコードはWindowsで機能します。何が問題になる可能性がありますか?Linuxマシンでは、デコーダーは文字列をデコードしません。