How to get file size in Java
In Java, we can use Files.size(path) to get the size of a file in bytes. // size in bytes long bytes = Files.size(path); 1. Files.size (NIO) This example uses NIO Files.size(path) to print the size of an image file (140 kb). GetFileSize.java package com.mkyong.io.howto; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class GetFileSize …