• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

RandomAccessFile

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to use RandomAccessFile class in conjunction with the DataInputStream class.?
-Thanks
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NO
RandomAccessFiles cannot be chained to streams. actually they do not work with streams.
others can explain better here why and other intracies about this.

Originally posted by Arsho, Ayan:
Is it possible to use RandomAccessFile class in conjunction with the DataInputStream class.?
-Thanks

 
Arsho, Ayan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
somebody please speak up .........
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RandomAccessFile and DataInputStream both implement the DataInput interface. That means that both of them can be used for the same goal but RandomAccessFile works directly on Files while DataInputStream works on streams... You are going to say "yes but DataInputStream can work on FileInputStream and thus Files too". The thing is that when you read a stream then you cannot come back to the beginning of the stream or anywhere on the stream. With RandomAccessFile you can do that, that is, read/write any position within a file.
HIH
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic