Tag Archives: File

Getting the size of a file


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();