Is there a Java equivalent of GetCompressedFileSize?

前端 未结 3 1886
一个人的身影
一个人的身影 2021-01-22 19:17

I am looking to get accurate (i.e. the real size on disk and not the normal size that includes all the 0\'s) measurements of sparse files in Java.

In C++ on Windows one

3条回答
  •  情歌与酒
    2021-01-22 19:29

    Since an answer was given for windows. i will try to supply for Linux.

    I am not sure, but i think it will do the trick (C++):

    #include 
    ioctl(file, BLKGETSIZE64, &file_size_in_bytes);
    

    This can be loaded in the same way that was described in the @Aniket answer (JNI)

提交回复
热议问题