Image I catch a stream of the net and count how many bytes went through my hands, I write this stream to a file. Is the number of counted bytes guranteed to be equal to the file.length() result (after flushing etc…)?
If you look at the Windows Explorer it gives you some different numbers (size on disk, real size,…).
Is the java file.length free of any OS and filesystem extensions to the file?
The javadoc only says: The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
Size on disk is how many bytes the file takes on the filesystem. It is not the file size. What
file.length()returns is, as you quoted from the javadoc, how many bytes you can read from the file. So yes, it is platform independent.if you’re reading bytes and writing bytes, without converting to strings, etc. Then yes.