Android File Size get getFileSize(File file)

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

Description

Returns file size.

Parameter

Parameter Description
file a parameter

Return

file size in bytes

Declaration

public static long getFileSize(File file) 

Method Source Code

import java.io.File;
import java.io.IOException;
import org.apache.log4j.Logger;

public class Main{
    /**/*from  w  w w.  j a  v  a2s .c  o  m*/
     * Returns file size.
     * 
     * @param file
     * @return file size in bytes
     * @see http://stackoverflow.com/questions/116574/java-get-file-size-efficiently
     */
    public static long getFileSize(File file) {
        if (file.exists()) {
            return file.length();
        } else {
            return 0;
        }
    }
}

Related

  1. sizeOf(File file)
  2. getFileSize(File f)
  3. getFileSizes(File f)
  4. fileLength(String filePath)
  5. fileLength(long length)