Java Utililty Methods File Size Get

List of utility methods to do File Size Get

Description

The list of methods to do File Size Get are organized into topic(s).

Method

intgetFileSize(String filename, String dir)
get File Size
File file = new File(dir, filename);
int size = (int) (file.length());
return size;
doublegetFileSize(String filePath)
Return file size in bytes.
double sizeInBytes = 0L;
File file = new File(filePath);
if (!file.exists() || !file.isFile()) {
    sizeInBytes = -1;
} else {
    sizeInBytes = file.length();
return sizeInBytes;
...
longgetFileSize(String filePath)
get File Size
long size = 0;
File file = new File(filePath);
if (file != null && file.exists()) {
    size = file.length();
return size;
doublegetFileSize(String filePath)
java get the file size
File file = new File(filePath);
return getFileSize(file);
longgetFileSize(String filepath)
file handling
if (filepath == null) {
    return 0;
} else {
    File f = toFile(filepath);
    return getFileSize(f);
DoublegetFilesize(String filepath)
get Filesize
File backupath = new File(filepath);
return Double.valueOf(backupath.length()) / 1000.000;
longgetFileSize(String filePath)
get File Size
return new File(filePath).length();
longgetFileSize(String filePath)
Get file size.
return getFileSize(new File(filePath));
StringgetFileSize(String fileSize)
get File Size
String temp = "";
DecimalFormat df = new DecimalFormat("0.00");
double dbFileSize = Double.parseDouble(fileSize);
if (dbFileSize >= 1024.0D) {
    if (dbFileSize >= 1048576.0D) {
        if (dbFileSize >= 1.073741824E9D) {
            temp = df.format(dbFileSize / 1024.0D / 1024.0D / 1024.0D) + " GB";
        } else {
...
longgetFileSize(String fn)
get File Size
File f = new File(fn);
if (!f.exists())
    return 0;
return f.length();