Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { public static long getFileSize(File file) { long s = 0; if (file != null && file.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(file); s = fis.available(); } catch (FileNotFoundException e) { } catch (IOException e) { } } return s; } }