Java File Read Sample Program

Program:

[java]
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class FileRead {

public static void main(String[] args) throws IOException {
int count =0;
byte[] byte_value = new byte[1024];

FileInputStream fis = new FileInputStream("D:\\javadomain.txt");
BufferedInputStream bis = new BufferedInputStream(fis);

while((count = bis.read(byte_value)) != -1){
String read = new String(byte_value,0,count);
System.out.println(read);
}

}

}[/java]

 

Output:

D:\javadomain.txt file has the below content,

Javadomain.in can provides a programming problem solutions.

Thanks for reading this post………….!!!

One comment

Leave a Reply