I am working on a project where I have to find the full file or the part of files stored on disk using java. Here is what i am doing
1) divide a reference file into parts(same in size of block size of file system) and create its hash and save in database
2) for search for that reference file, I divide the disk into parts(same size of block size of file system) and create hash and then look for the match of hashes.
Now all is fine until I reach the last part of file which will most probably NOT be equal to the block size of file system. and same is the case when file was stored on the disk.so the hashes do not match of course.
So how can I find this last part of file with size less than block size of file system? Why are you concerned about the physical block size? Between the harddisk and the OS, they can't even agree whether it's 512 bytes or 4KB. And modern SSDs compress the data on the fly, making a mockery of the whole notion of block size. Your algorithm would still work if you just divide the file in 4KB blocks regardless of the underlying storage system, so just hardcode that.
以上就是how to find last part of file(with size less than block size of file system) on the disk using java?的详细内容，更多请关注web前端其它相关文章！