This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check file size on disk  RSS feed

 
scott Edwards
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to check the size that a file occupies on disk, not the actual file size.
Could somebody please help me out?
Thanks a lot.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meaning the size of the allocation blocks dedicated to the file, I presume.
I don't think there's any way to do this from Java.
 
scott Edwards
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I mean
the size of the allocation blocks dedicated to the file.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java there is nothing to do with hadware or Operating System. You can only find the No. of bytes in a File not in terms of disk space.
The only way is to write Operating System Specific code (in C Language)to find out the file size and access the code using JNI from Java.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!