Get total size of file in bytes

Illep picture Illep · Jan 23, 2013 · Viewed 205.3k times · Source

Possible Duplicate:
java get file size efficiently

I have a File called filename which is located in E://file.txt.

FileInputStream fileinputstream = new FileInputStream(filename);

What I want to do is to calculate the size of this file in bytes. How can I have this done?

Answer

Swapnil picture Swapnil · Jan 23, 2013

You can use the length() method on File which returns the size in bytes.