+ 1
Import java.io.BufferedReader; import java.io. InputStreamReader?
BufferedReader, InputStreamReader. What is work of these two keyword or function? I don't know what should I call these things I started java just some days
1 Answer
0
InputStream -> To read data from a source.
OutputStream -> To write data to a destination.
ByteStreams -> Classes related to 8-bit Bytes. Most important among them include 1)File InputStream-For reading data from files.
2)File OutputStream-To create a file and/or write data into it.
// Headers used include
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.FileOutputStream; //etc.
//Sample program with Buffered Reader
public class NewClass {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter content");
String s = br.readLine();
System.out.println("Entered content is "+s);
}
}