Science
to create java program using buffered reader

Question Description

How to create java program using buffered reader.  to create java program using buffered reader.  to create java program using buffered readersdnsjf dkfndksfns skfskf

Final Answer

Buffered Reader is a class which uses an InputStream Reader object to read  characters from a stream. If using System.in in the Inputstream Reader class, we can read the typed characters.
We can use the read() or readLine() functions to read data. read() will read a character and readLine() will read a whole line of characters(till you press enter). Also it throws an IOException which we must handle in our program
We also need to import java.io as it contains the necessary classes.

An example program


import java.io.*;
public static void main (String[] args) throws IOException

// throwing the IO exception which the buffered reader may generate
{

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

int T=Integer.parseInt(br.readLine());
for(int i=0;i<T;i++){
	String s= br.readLine();
//read a line as string
	int[] m=newint[2];//create a 2 member array
        m[0]=br.read();//read the first number
        m[1]=br.read();
//read the second number

System.out.println(s);
//print out the string

System.out.println(m[0]);
//print out the first number

System.out.println(m[1]);
}
}

tarangshah (11)
Cornell University

Anonymous
Thanks for the help.

Anonymous
Outstanding. Studypool always delivers quality work.

Anonymous
Tutor was very helpful and took the time to explain concepts to me. Very responsive, managed to get replies within the hour.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors