Example usage for org.apache.commons.io FileUtils sizeOfDirectory

List of usage examples for org.apache.commons.io FileUtils sizeOfDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils sizeOfDirectory.

Prototype

public static long sizeOfDirectory(File directory) 

Source Link

Document

Counts the size of a directory recursively (sum of the length of all files).

Usage

From source file:Main.java

public static void main(String[] args) {
    long size = FileUtils.sizeOfDirectory(new File("C:/Windows"));
    System.out.println("Size: " + size + " bytes");
}

From source file:jease.cms.service.Informatons.java

public static String getDatabaseSize() {
    return FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(new File(getDatabaseDirectory())));
}

From source file:com.doculibre.constellio.utils.FileSizeUtils.java

public static String formatSize(File file, int decimalPos) {
    long fileSize;
    if (file.isDirectory()) {
        fileSize = FileUtils.sizeOfDirectory(file);
    } else {//from w  ww  .  j  av a  2 s.c  o  m
        fileSize = file.length();
    }
    return formatSize(fileSize, decimalPos);
}

From source file:com.splunk.shuttl.archiver.model.LocalBucket.java

private static Long setSizeOnNullSizedLocalBucket(File directory, Long size) {
    return size == null ? FileUtils.sizeOfDirectory(directory) : size;
}

From source file:jease.cms.service.Informations.java

public String getDatabaseSize() {
    return FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(new File(getDatabaseDirectory())));
}

From source file:ca.uviccscu.lp.persistence.GamelistStorage.java

public static synchronized boolean checkGameChanged(Game g) throws IOException {
    l.trace("Checking if game same: " + g.gameName);
    File f = new File(g.gameAbsoluteFolderPath);
    lastFileNumber = FileUtils.listFiles(f, null, true).size();
    boolean a = (g.gameFileNumber == lastFileNumber);
    lastCRC = FileUtils.checksumCRC32(new File(g.gameAbsoluteExecPath));
    boolean b = (g.gameExecCRC32 == lastCRC);
    lastSize = FileUtils.sizeOfDirectory(f);
    boolean c = (g.gameSize == lastSize);
    l.trace("File number same: " + a + "| Exec CRC32 same: " + b + "| Size same: " + c);
    return !(a && b && c);
}

From source file:fr.inria.eventcloud.load_balancing.criteria.DiskUsageCriterion.java

/**
 * {@inheritDoc}// www .jav a  2s .c o m
 */
@Override
public double getLoad(SemanticCanOverlay overlay) {
    return ((FileUtils.sizeOfDirectory(this.directory) * 100) / (double) this.virtualCapacity);
}

From source file:com.apporiented.hermesftp.cmd.impl.FtpCmdSize.java

/**
 * {@inheritDoc}/*from  w  w  w.ja va  2  s .c  om*/
 */
public void execute() throws FtpCmdException {
    File path = new File(getPathArg());
    if (!path.exists()) {
        msgOut(MSG550);
    } else if ((getCtx().getPermission(path.getAbsolutePath()) & PRIV_READ) == 0) {
        msgOut(MSG550_PERM);
    } else if (path.isDirectory()) {
        msgOut(MSG213_SIZE, new Object[] { FileUtils.sizeOfDirectory(path) });
    } else {

        /* This is the binary length. In ASCII mode the size may differ, see RFC 3659, chap. 4 */
        msgOut(MSG213_SIZE, new Object[] { path.length() });
    }
}

From source file:it.anyplace.sync.core.cache.FileBlockCache.java

public FileBlockCache(File cacheDirectory) {
    this.dir = cacheDirectory;
    if (!dir.exists()) {
        dir.mkdirs();/*from   ww w . j  av a  2s .  co m*/
    }
    checkArgument(dir.isDirectory() && dir.canWrite());
    size = FileUtils.sizeOfDirectory(dir);
    runCleanup();
}

From source file:com.gwos.server.services.AppsServiceImpl.java

@Override
public StatObject getMemoryStats() {
    StatObject stats = new StatObject();

    // The FS root dir
    File rootDir = new File(new ServiceUtils(getServletContext()).getFSPath());
    stats.fileSystemTotalSpace = FileUtils.sizeOfDirectory(rootDir);

    // Call the service
    SessionServiceImpl service = new SessionServiceImpl();
    try {/* www.j a  v  a 2 s .  c  o  m*/
        service.init(this.config);
    } catch (ServletException e) {
        e.printStackTrace();
    }

    // Memory for each of app users
    Map<User, Long> memoryUsages = new HashMap<User, Long>();
    stats.memoryUsages = memoryUsages;
    for (User user : service.getAllUsers()) {
        File userDir = new File(rootDir.getAbsolutePath() + File.separator + user.getUsername());
        if (userDir.exists() == false) {
            continue;
        }
        memoryUsages.put(user, FileUtils.sizeOfDirectory(userDir));
    }

    return stats;
}