示例

public static void main( String[] args ) {
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter("file1"); //$NON-NLS-1$
fileWriter.write( "\uceba" ); //$NON-NLS-1$
} catch ( IOException e ) {
e.printStackTrace();
}
}

解决方案
要指定您自己的字符编码值,应对 FileOutputStream 构造一个 OutputStreamWriter。

public static void main( String[] args ) {

OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream("file1"), //$NON-NLS-1$
"UTF-16BE"); //$NON-NLS-1$
writer.write( "\uceba" ); //$NON-NLS-1$
writer.flush();
} catch ( IOException e ) {
e.printStackTrace();
}

}