Here you can find the source of getFileSize(File file)
public static long getFileSize(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static long getFileSize(File file) { long fileSize = 0; if (file.exists()) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { fileSize += getFileSize(files[i]); }/* w ww . j a v a 2s . co m*/ } else { fileSize = file.length(); } } return fileSize; } public static boolean exists(String filePath) { return new File(filePath).exists(); } }