예제

public static void main( String[] args ) {
// Assume default charset ISO-8859-1 and file with UTF-16BE content
FileReader fileReader = null;
try {
fileReader = new java.io.FileReader( "file1" ); //$NON-NLS-1$
System.out.println( fileReader.read() );
} catch ( IOException e ) {
e.printStackTrace();
}
}



솔루션
문자 인코딩 값을 직접 지정하려면 FileInputStream에 CharsetDecoder로 InputStreamReader를 구성하십시오.

public static void main( String[] args ) {
// Assume default charset ISO-8859-1 and file with UTF-16BE content
InputStreamReader reader = null;
try {
reader = new InputStreamReader( new FileInputStream("file1"), "UTF-16BE");
System.out.println( reader.read() );
} catch ( IOException e ) {
e.printStackTrace();
}

}