Languages
[Edit]
EN

Java - get file size

3 points
Created by:
Palusbug
515

In this article, we would like to show you how to get file size in Java.

Below we present 3 methods of getting the file size:

  • File.length()
  • Files.size()
  • FileChannel.size()

1. Using File.length() method.

Edit

 Output: 

File used in example - the file size is consistent with the program results.
File used in example - the file size is consistent with the program results.

 2. Using Files.size() method.

Edit

Output: 

3. Using FileChannel.size() method.

Edit

Output: 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - file operations

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join