Java BufferedReader.read()
Syntax
BufferedReader.read() has the following syntax.
public int read() throws IOException
Example
In the following code shows how to use BufferedReader.read() method.
//from w w w .ja va 2 s . c o m
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
InputStream is = new FileInputStream("c:/test.txt");
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
int value = 0;
while ((value = br.read()) != -1) {
char c = (char) value;
System.out.println(c);
}
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »