Java File Size Get getFileSize(File file)

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

Description

Returns file size.

License

Open Source License

Parameter

Parameter Description
file a parameter

Return

file size in bytes

Declaration

public static long getFileSize(File file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**//from   www.j a v a  2  s  . 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. getFileSize(File file)
  2. getFileSize(File file)
  3. getFileSize(File file)
  4. getFileSize(File file)
  5. getFileSize(File file)
  6. getFileSize(File[] files)
  7. getFileSize(final String filename)
  8. getFileSize(final String filePath)
  9. getFileSize(final String path)