Java InputStreamReader .getEncoding ()

Syntax

InputStreamReader.getEncoding() has the following syntax.

public String getEncoding()

Example

In the following code shows how to use InputStreamReader.getEncoding() method.


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
//from ww  w.  ja v  a 2  s. c  om
public class Main {
  public static void main(String[] args) throws IOException {
    // new input stream reader is created
    FileInputStream fis = new FileInputStream("C:/test.txt");
    InputStreamReader isr = new InputStreamReader(fis);

    // the name of the character encoding returned
    String s = isr.getEncoding();
    System.out.print("Character Encoding: " + s);
    isr.close();
  }
}