Advertisement
InputStreamReader(InputStream is) |
---|
This constructor creates an InputStreamReader object wrapped around an InputStream to read data from it in the form of characters. Example-:
|
Methods | Description |
---|---|
available() | This method gives the remaining number of bytes available to read from this character input stream's buffer. |
read() | This method reads one character at a time from this character input stream's buffer. |
read(char[]) | This method reads a whole character array at a time from this character input stream's buffer. |
close() | This method closes this input stream and also frees any resources connected with this character input stream. |
Advertisement
// Program to create an input stream for reading the data and convert bytes to character while reading a byte
//stream
import java.io.*;
class A
{
public static void main(String... ar)
{
try
{
FileInputStream fis= new FileInputStream("TextBook9.txt");
InputStreamReader isr= new InputStreamReader(fis);
int c;
while( (c=isr.read())!=-1)
{
System.out.print((char)c);
}
}
catch(IOException e)
{
System.out.println(e);
}
}
}
Hello there!
How are you doing?
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement