How do you get a file on disk, not just file size in Java?

I need file size on disk, not file size

File myFile = new File ("C:\\Send\\Capture.png"); System.out.println((int)myFile.length()); 

^ This code gives the file size. I need the file size on disk. They are always different, as in the figure below, right?

enter image description here

+7
source share
1 answer

See link

the answer is provided for C #, but since it uses the Win32 API functions, you can easily convert it to java. function used to get size on disk, GetCompressedFileSize

hope that helps

0
source

All Articles