2

I'm building a Download manager and I'm trying to optimise it by setting disk buffer size to the system block size... but the problem is there is no such thing in java that allows to get system file block size so i came up with an idea and that is if i store a file that is 1 byte on disk then i calculate "size on disk" so i get the block size of file system which is for me 4 kbyte. example:

enter image description here

so can this be done in java??

Karim
  • 97
  • 1
  • 9
  • 3
    By curiosity, why do you want to do this by hand? Why not just let the filesystem handle that kind of stuff? – fge Apr 07 '16 at 11:17
  • we suppose that the file system does not do the optimisation by default as our application intended to be cross platform – Karim Apr 07 '16 at 11:20
  • 1
    All the more a reason to let the fs handle that then. And you fail to account for filesystems like btrfs, for instance, which store the data "inline" along with the metadata if the content is small. reiserfs does the same, too. – fge Apr 07 '16 at 11:22
  • Note: the file size on disk can be much smaller than the length/extents. Windows supports compressed files and Linux supports sparse files. – Peter Lawrey Apr 07 '16 at 11:39

0 Answers0