First, please do not miss, because you might think that this is a general question, it is not. I know how to find out the file and directory size using file.lengthand ApacheFileUtils.sizeOfDirectory .
My problem is that the files and directory size are too large (in hundreds of mb). When I try to figure out the size using the code above (for example, creating a file object), my program becomes so resource intensive and slows down performance.
Is there a way to find out the file size without creating an object?
I use for files File file1 = new file (filename); long size = file1.length ();
and for the directory, File dir1 = new file (dirPath); long size = fileUtils.sizeOfDirectiry (dir1);
I have one parameter that allows me to calculate the size. If the parameter is false, then it goes smoothly. If false, the program slows down or freezes. I calculate the size of 4 directories and 2 database files.
source
share