Java – data input stream required

What's the difference?

FileInputStream fstream = new FileInputStream ("file1.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));

and

FileInputStream fstream = new FileInputStream ("file1.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));

Do we really need a datainputstream?

Solution

The important thing about the object passed to the inputstreamreader () constructor is that it will be the object that carries the weight of any synchronization hold If you don't want your FileInputStream to be blocked by multiple calls, the second option is a viable method See the source of reader

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>