Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new BufferedInputStream(new RandomAccessFile()) dosent work ..why?  RSS feed

 
john wesley
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i am trying to randomly read a chunk of data from a file. however, BufferedInputStream does not accept RandomAccessFile in its constructor ... wonder why ?

RandomAccessFile RAF = new RandomAccessFile("c:\\BDB.csv", "r");
BufferedInputStream bis = new BufferedInputStream(RAF,20) //problem
bis.read(buff)



please help!
.....jw
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though it may seem counterintuitive, RandomAccessFile is not a File, nor does it extend File. It performs many of the tasks a File does, but it encapsulates the read/write methods by implementing DataInput/Output directly, rather than having you wrap it with streams.

Take a look at the JavaDocs for the class and you'll see how you can use it. The JavaDocs should always be your first source when learning to use a new class. If you're not familiar with them, they are installed with your JDK and available online.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!