有什么区别
FileInputStream fstream = new FileInputStream ("file1.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
和
FileInputStream fstream = new FileInputStream ("file1.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in));
我们真的需要一个DataInputStream吗?
解决方法
传递给InputStreamReader()构造函数的对象的重要之处在于它将是承载任何同步保持的权重的对象.如果您不希望您的FileInputStream可能被多次调用阻止,那么第二个选项就是可行的方法.见
the source of
Reader
.