在 Java 7 中如何可移植地获取文件存储的块大小?
我查看了 java.nio.file.attribute.Attributes
和 java.nio.file.FileStore
,但找不到找到块大小的方法磁盘文件的。
I've looked at java.nio.file.attribute.Attributes
and java.nio.file.FileStore
, but couldn't find a way to discover the block-size of a disk-file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一篇关于缓冲区大小与 I/O 吞吐量的文章 。简介:nio 为您处理所有这些事情。这篇SO帖子得出的结论是您应该使用 2 的幂。
Here is an article on buffer size vs I/O throughput. Synopsis: nio handles all of that for you. This SO post concludes you should use a power of 2.
Java 7没有所请求的信息,用户的问题与Java 7有关。
但是在Java 10中,引入了一种新方法来提供所请求的信息。
getBlockSize() 方法用于返回此文件存储对象中每个块的字节数。每个文件存储都被组织成称为块的离散字节序列,块是文件存储的最小存储单元。每次读写操作都是在多个块上执行的。该方法有助于获取Block的大小。
Java 7 does not have the requested information, and the users question is related to Java 7.
But in Java 10, there was a new method introduced which provides the requested information.
The getBlockSize() method of a FileStore class is used to return the number of bytes per block in this file store Object. Every File storage is organized into discrete sequences of bytes called blocks and a block is the smallest storage unit of a file store. Every read and write operation is performed on multiple blocks. This method is helpful in getting the size of Block.