title: how to find out the size of file and directory in java without creating the object?
body: <p>First please dont overlook because you might think it as common question, this is not. I know how to find out size of file and directory using <code>file.length</code> and <a href="http://commons.apache.org/io/apidocs/org/apache/commons/io/FileUtils.html#sizeOfDirectory%28java.io.File%29" rel="nofollow">Apache <code>FileUtils.sizeOfDirectory</code></a>.</p>
  
  <p>My problem is, in my case files and directory size is too big (in hundreds of mb). When I try to find out size using above code (e.g. creating file object) then my program becomes so much resource hungry and slows down the performance. </p>
  
  <p>Is there any way to know the size of file without creating object?</p>
  
  <p>I am using 
  for files File file1 = new file(fileName); long size = file1.length(); </p>
  
  <p>and for directory, File dir1 = new file (dirPath); long size = fileUtils.sizeOfDirectiry(dir1);  </p>
  
  <p>I have one parameter which enables size computing. If parameter is false then it goes smoothly. If false then program lags or hangs.. I am calculating size of 4 directory and 2 database files.</p>