Basic HTML version of Foils prepared Sept 21 1998

Foil 39 Random Access

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

Random Access Files for Foil 39
1 The RandomAccessFile class offers all the functionality of DataInputStream and DataOutputStream combined, plus additional capabilities.
2 To open a random access file for reading, use:
  • RandomAccessFile in =
  • new RandomAccessFile( filename, "r" );
  • Such a file may be accessed sequentially with
  • in.readLine();
  • or randomly by repositioning the file pointer:
  • in.seek( offset );
  • where offset is a byte offset into the random file. (Use "rw" for read/write access.)
3 Random access files have no inherent structure; the structure must be imposed by the programmer.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998