The length() method from Java IO returns the length of the file. If given File object represents the directory the method will return unspecified value.
2. Method signature
- method does not take any parameter
- long - the file lenght in bytes, or 0L if the file does not exist
- SecurityException - when we do not have access to the file or directory
3.1. Print length of the file that does not exist and file with a short text inside
In this article, we presented a method that returns the length of the file in bytes.