Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO streams

 
Mahesh Kumar Chintakayala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between DataInputStrean and RandomAccessFile
 
Amir Alagic
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You often want to read or write data at random positions within a file, rather than sequentially as you would with a magnetic tape. The RandomAccessFile class behaves like a combined DataOutputStream and DataInputStream. RandomAccessFile implements both the DataOutput and DataInput interfaces. RandomAccessFile objects are created from a String filename or File object like other stream objects, but a mode constructor argument is also required.
http://www.cs.usfca.edu/~parrt/course/601/lectures/io.html
 
sajja bala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahesh

First you go through the API and ask the question of RandomAccessFile and Data...........
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Streams are like rivers ... you can't really ask them to back up. The IO chapter in Eckell's Thinking In Java (free online) breaks down the confusing hierarchy of IO classes pretty well.

BTW: The languages I used could SEEK and READ BACKWARDS on magnetic tape. It used to be great fun to watch a bank of 8 tape drives do sorts, running backwards and forwards all over the place. You could see the sort algorithm at work and easily tell how well sorted the input was.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic