Read a file int by int in Java
Description
The following code shows how to read a file int by int.
Example
//from ww w.j a va 2 s . c o m
import java.io.FileInputStream;
class FileInputStreamDemo {
public static void main(String args[]) throws Exception {
FileInputStream fis = new FileInputStream("Main.java");
// Read and display data
int i;
while ((i = fis.read()) != -1) {
System.out.println(i);
}
fis.close();
}
}