Java File Size Get getFileSize(File f)

Here you can find the source of getFileSize(File f)

Description

get File Size

License

Open Source License

Declaration

public static long getFileSize(File f) throws Exception 

Method Source Code

//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;
    }
}

Related

  1. fileSizeString(long bytes)
  2. getFileKBSize(long fsize)
  3. getFileSize(@Nonnull File file)
  4. getFileSize(File dir)
  5. getFileSize(File element)
  6. getFileSize(File file)
  7. getFileSize(File file)
  8. getFileSize(File file)
  9. getFileSize(File file)