若要自行指定字元編碼值,請在 FileInputStream 上以 CharsetDecoder 建構 InputStreamReader
public static void main( String[] args ) {
InputStreamReader reader = null;
try {
reader = new InputStreamReader( new FileInputStream("file1"), "UTF-16BE");
System.out.println(reader.read());
} catch ( IOException e ) {
e.printStackTrace();
}
}
|
|