Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic