Searching...
Friday, 27 September 2013

How to read file in Java? (BufferedReader Example)

11:11

Java provides many API to read files , here is once simple example to read a file using Buffered Reader

package com.pretech;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class BufferedReaderExample {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new FileReader("c://buffertext.txt"));
		String value;
		while ((value = bf.readLine()) != null) {
			System.out.println(value);
		}
	}
}

0 comments: