您如何在磁盘上获取文件,而不仅仅是Java中的文件大小? [英] How do you get the file on disk, and not just the file size in Java?
本文介绍了您如何在磁盘上获取文件,而不仅仅是Java中的文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要磁盘上的文件大小,而不是文件大小
I need the filesize on disk and not the 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 always happen to be different, like in the pic below, right?
推荐答案
看看答案是为c#提供的,但是由于它使用win32 API函数,因此您可以轻松地将其转换为java.用于获取磁盘大小的函数为
the answer is provided for c# , but since it uses win32 API functions , you can easily convert it to java. the function used to get the size on disk is GetCompressedFileSize
希望有帮助
这篇关于您如何在磁盘上获取文件,而不仅仅是Java中的文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文