public long getFileSize(File file) throws IOException { long size = 0; if (file.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(file); size = fis.available(); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (fis != null) fis.close(); } } return size; }