• Post Reply Bookmark Topic Watch Topic
  • New Topic

Size of a file from Java Code  RSS feed

 
kajalsingh singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I would like to know, if it is possible to read the size of a file from the java code.
I checked java.io.File API, but there was no method relating to file size.
If there is a work around to get file size, Please send me the code.
Thanks,
Kaj
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked java.io.File API, but there was no method relating to file size.
Try length().
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kajalsingh singh:
If there is a work around to get file size, Please send me the code.

No need for work around. The length() method in the File class will give you the size of the file in bytes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!