在开发新系统或者预测未来的业务量,经常需要评估下容量、文件大小。
redis容量的预估:
http://www.searchdatabase.com.cn/showcontent_55189.htm
文件大小的评估:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package java_code;
import java.io.File;
public class FileSize {
     public static long getFileSize(String filename) {
          File file = new File(filename);
          if (!file.exists() || !file.isFile()) {
             System.out.println("文件不存在");
             return -1;
          }
          return file.length();
       }
       public static void main(String[] args) {
          long size = getFileSize("d:/u");
          System.out.println("文件大小为: " + size+" Byte");
       }
}