java bufferedreader import code example

Example 1: java read file bufferedreader

try {
	File file = new File("data.txt");
	BufferedReader reader = new BufferedReader(new FileReader(file));
	String line;

	while((line = reader.readLine()) != null) {
	 	 System.out.println(line);
	}
} catch(IOException e) {
  	e.printStackTrace();
}

Example 2: bufferedreader java

import java.io.BufferedReader;
//
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println(reader.readLine());

Example 3: declare bufferedreader java

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Tags:

Java Example