Read the file one buffer at a time in Java
Description
The following code shows how to read the file one buffer at a time.
Example
/* ww w. ja v a 2 s.co m*/
import java.io.FileReader;
public class Main {
public static void main(String[] argv) throws Exception {
FileReader fr = new FileReader("text.txt");
int count;
char chrs[] = new char[80];
do {
count = fr.read(chrs);
for (int i = 0; i < count; i++)
System.out.print(chrs[i]);
} while (count != -1);
}
}