How to get size of file in java

In this post, we will see how to get size of file in java. We can directly use java.io.File ‘s length method to get its size in bytes. We can convert it to KB and MB accordingly.
When you run above program, you will get following output:

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *