try {
// create a reader
FileInputStream fis = new FileInputStream(new File("input.dat"));
BufferedInputStream reader = new BufferedInputStream(fis);
// read one byte at a time
int ch;
while ((ch = reader.read()) != -1) {
System.out.print((char) ch);
}
// close the reader
reader.close();
} catch (IOException ex) {
ex.printStackTrace();
}