Hello all...
According to
Java API:- The Seek() will read the next byte from the file pointer position. The first byte being at position 0.
Now look at the below snippet of code:-
{
RandomAccessFile raf = new RandomAccessFile("test1.txt" , "rw");
for (int i=0; i<10; i++)
raf.write(i);
raf.seek(1);
out = raf.readByte();
raf.close();
System.out.println(out);
}
// The No's written will be :- 0 1 2 3 4 5 6 7 8 9 (Each occupying 1 byte.)
So here the filepointer using seek(1) will be placed on 1 & the next
byte read will be 2, but here the output is 1.
Can someone explain me where i m wrong.
Also i want to know how many bytes does the method raf.write(i) takes
Thanks.