soham
soham

Reputation: 1668

How frequently is RandomAccessFile length updated?

I have a Java RandomAccessFile. I check the length of the file frequently. The file is coming from an scp. Therefore, the file is getting appended.

I want to know how frequently the RandomAccessFile is updated. Whenever I check RandomAccessFile.length, will get I the accurate length?

Upvotes: 1

Views: 428

Answers (1)

Jens Egholm
Jens Egholm

Reputation: 2710

Since the method is native, I'd recommend taking a look in the OpenJDK source code. It's the closest thing you'll get to the actual implementation (unless you work for Oracle ;-).

The source can be found here (it's shared between all OS): src/share/native/java/io/RandomAccessFile.c

tl;dr Yes, it will try to find the end of the file descriptor the RandomAccessFile is referring to.

Upvotes: 2

Related Questions