本文整理汇总了Java中org.apache.commons.io.FileUtils.sizeOfDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.sizeOfDirectory方法的具体用法?Java FileUtils.sizeOfDirectory怎么用?Java FileUtils.sizeOfDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.sizeOfDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Compare the length of two files.
*
* @param file1 The first file to compare
* @param file2 The second file to compare
* @return a negative value if the first file's length
* is less than the second, zero if the lengths are the
* same and a positive value if the first files length
* is greater than the second file.
*
*/
public int compare(File file1, File file2) {
long size1 = 0;
if (file1.isDirectory()) {
size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0;
} else {
size1 = file1.length();
}
long size2 = 0;
if (file2.isDirectory()) {
size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0;
} else {
size2 = file2.length();
}
long result = size1 - size2;
if (result < 0) {
return -1;
} else if (result > 0) {
return 1;
} else {
return 0;
}
}
示例2: actionPerformed
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
cacheFile = new File(Constant.CACHE_PATH);
if (!cacheFile.exists()) {
cacheFile.mkdirs();
}
long size = FileUtils.sizeOfDirectory(cacheFile);
DialogBuilder builder = new DialogBuilder();
builder.setTitle(Constant.TITLE);
builder.resizable(false);
builder.setCenterPanel(new JLabel(String.format("Currently occupy storage %.2fM, "
+ "Clean Cache immediately?", size/1024.0/1024.0),
Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText("Clean Now");
builder.addCancelAction().setText("Cancel");
builder.setButtonsAlignment(SwingConstants.RIGHT);
if (builder.show() == 0) {
clean();
}
}
示例3: accept
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public boolean accept(File pathname) {
if (pathname.getName().startsWith(FilenameUtils.getBaseName(recordFileName) + "_")) {
if (pathname.isFile()) {
// total += pathname.length();
total += FileUtils.sizeOf(pathname);
} else {
pathname.listFiles(this);
total += FileUtils.sizeOfDirectory(pathname);
}
}
return false;
}
示例4: getFileSize
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* return the file size.
*
* @return the file size.
*/
@Override
public long getFileSize() {
return FileUtils.sizeOfDirectory(DIR);
}
示例5: getFileSize
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* return the file size.
*
* @return the file size.
*/
@Override
public long getFileSize() {
return FileUtils.sizeOfDirectory(fileSizeDir);
}