若要自行指定字元編碼值,請在 FileOutputStream 上建構 OutputStreamWriter
public static void main( String[] args ) {
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream("file1"),
"UTF-16BE");
writer.write( "\uceba" );
writer.flush();
} catch ( IOException e ) {
e.printStackTrace();
}
}
|
|