Java examples for File Path IO:File Attribute
Get File size in bytes
import java.io.*; public class Main { public static void main(String[] args) { File file = new File("C://Folder/demo.txt"); long fileSize = file.length(); System.out.println("File size in bytes is: " + fileSize); System.out.println("File size in KB is : " + (double)fileSize/1024); System.out.println("File size in MB is :" + (double)fileSize/(1024*1024)); }/*from w ww .j av a 2s . co m*/ }