Getting the size of a file



Introduction

We already know about the java.util.File Object from other examples. It is possible to determine the filesize once you have the File Object. This example shows how to do it:

File file = new File("/path/to/file");

// Get the number of bytes in the file
long length = file.length();

 

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.