working with java get file size, one of case is:
i create one file on linux with hole, as the following:
ls -ltr hole.f
-rw------- 1 root root 1073741838 Apr 15 09:56 hole.f
the size returned by ls , is 1073741838, but the actual occupied size is just 8k.
du -sh hole.f
8.0K hole.f
File.length return as 1073741838. is there any java api could return 8k?
i do not want to use RunTime api.
ps: jnr could not resolve my requirement as there is run time exception: Exception in thread "main" java.lang.IllegalStateException: stat.st_blocks is not implemented in jnr-posix at jnr.posix.util.DefaultPOSIXHandler.unimplementedError(DefaultPOSIXHandler.java:28) at jnr.posix.JavaFileStat.blocks(JavaFileStat.java:105) at AA.main(AA.java:30)