1try {
2 File file = new File("data.txt");
3 BufferedReader reader = new BufferedReader(new FileReader(file));
4 String line;
5
6 while((line = reader.readLine()) != null) {
7 System.out.println(line);
8 }
9} catch(IOException e) {
10 e.printStackTrace();
11}
1import java.io.BufferedReader;
2//
3BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
4System.out.println(reader.readLine());
1class Main {
2 public static void main (String[] args) throws IOException{
3
4 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
5 String[] str = br.readLine().split(" "); // 6 2
6 String[] input = br.readLine().split(" "); // 1 2 3 4 5 6
7
8
9 int n = Integer.parseInt(str[0]); // 6
10 int k = Integer.parseInt(str[1]); // 2
11
12
13 int [] arr = new int [n];
14
15 for(int i=0; i<n; i++)
16 {
17 arr[i] = Integer.parseInt(input[i]); // 1 2 3 4 5 6
18 }
19
20
21 }
22}
23
1package com.javatpoint;
2import java.io.*;
3public class BufferedReaderExample {
4 public static void main(String args[])throws Exception{
5 FileReader fr=new FileReader("D:\\testout.txt");
6 BufferedReader br=new BufferedReader(fr);
7
8 int i;
9 while((i=br.read())!=-1){
10 System.out.print((char)i);
11 }
12 br.close();
13 fr.close();
14 }
15}
1package com.javatpoint;
2import java.io.*;
3public class BufferedReaderExample{
4public static void main(String args[])throws Exception{
5 InputStreamReader r=new InputStreamReader(System.in);
6 BufferedReader br=new BufferedReader(r);
7 System.out.println("Enter your name");
8 String name=br.readLine();
9 System.out.println("Welcome "+name);
10}
11}