Mega Code Archive

 
Categories / Java Tutorial / File
 

InputStreamReader

An InputStreamReader reads bytes and translates them into characters using the specified character set. InputStreamReader is ideal for reading from the output of an OutputStreamWriter or a PrintWriter. The InputStreamReader class has four constructors: public InputStreamReader (InputStream in) public InputStreamReader (InputStream in, java.nio.charset.Charset cs) public InputStreamReader (InputStream in, java.nio.charset.CharsetDecoder, dec) public InputStreamReader (InputStream in, String charsetName) To create an InputStreamReader: InputStreamReader reader = new InputStreamReader(new FileInputStream (filePath), charSet);