This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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!