日期:2014-05-20  浏览次数:20580 次

FilterInputStream和RandomAccessFile的问题,求达人解释
小弟我之前写了一个程序,输入数据和读取数据都是通过RandomAccessFile来操作。现在要对程序进行升级,打算在输入和读取数据时通过写一个FilterInputStream的子类来过滤,但子类read方法要用到InputStream来导入数据,请问要怎么把InputStream与RandomAccessFile拼接起来,似乎
InputStream in = new BufferedInputStream(new RandomAccessFile("Guests.dat","rw"));
这样的构造函数是不存在的,有什么其他方法没?

------解决方案--------------------
Java code

  RandomAccessFile infile = new RandomAccessFile("Guests.dat","rw");
 FileInputStream fileStream = new FileInputStream(infile.getFD());

------解决方案--------------------
没关系吧 注意不要直接读取二进制数据就行了