Here you can find the source of getFileSize(File f)
public static long getFileSize(File f) throws Exception
//package com.java2s; import java.io.File; import java.io.FileInputStream; public class Main { public static long getFileSize(File f) throws Exception { long s = 0; if (f.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(f); s = fis.available();// ww w. ja v a 2 s . co m } catch (Exception e) { e.printStackTrace(); } finally { fis.close(); } } return s; } }