Saturday, February 18, 2012

Java Program- Read Bytes

 Read File in Java 
package testFileHandling;
import java.io.*;
public class Byteread {

/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
FileInputStream fin=new FileInputStream("C://data.txt");
int i=0;
while(i != -1) {
try {
i=fin.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print((char)i);
}

//fin.close();
fin=null;
}

}

No comments:

Post a Comment