Java File Size Get getFileSize(String fileName, Logger log)

Here you can find the source of getFileSize(String fileName, Logger log)

Description

get File Size

License

Open Source License

Declaration

public static long getFileSize(String fileName, Logger log) 

Method Source Code


//package com.java2s;
import java.io.File;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static long getFileSize(String fileName, Logger log) {
        File file = new File(fileName);

        //// ww  w.  j  av  a2s  .  c om
        // File is supposed to be on disk already, since the file was used for
        // the first time
        //
        if (!file.exists()) {
            if (log != null)
                log.log(Level.WARNING, "File \"" + fileName + "\" not found, so size is zero");
            return 0;
        }

        return file.length();
    }
}

Related

  1. getFileSize(long fileSize)
  2. getFilesize(String address)
  3. getFileSize(String fileName)
  4. getFileSize(String filename)
  5. getFileSize(String filename)
  6. getFileSize(String filename, String dir)
  7. getFileSize(String filePath)
  8. getFileSize(String filePath)
  9. getFileSize(String filePath)