Java File Read Sample Program

Program:

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);
		}

	}

}

 

Output:

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

Javadomain.in can provides a programming problem solutions.

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

149 total views, 3 views today

Leave a Reply

Your email address will not be published. Required fields are marked *