File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Explain the role of seek() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Explain the role of seek()" Watch "Explain the role of seek()" New topic

Explain the role of seek()

Stephen Joseph
Ranch Hand

Joined: Dec 29, 2000
Posts: 50

Hello everyone
Please check this out.I want to know the exact role of the method seek() what does it do.Why is the output=20.
class SeekTest
public static void main(String args[])
FileOutputStream fos = new FileOutputStream("xx");
for (byte b=10; b<50; b++)

RandomAccessFile raf = new RandomAccessFile("xx", "r");;
int i =;
System.out.println("i = " + i);

catch(FileNotFoundException ee)

catch(IOException e)


Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
Seek is like a the file. what that statement nmeans is go to the 10 place and then read the data . All thge data before that will be skipped.

Sandeep Jain

Try and Try Till u succeed<br /> <br />Sandeep Jain
I agree. Here's the link:
subject: Explain the role of seek()
It's not a secret anymore!