package com.swiftcleaner.chovey.model.tool;


public class FileSizeUtil {
    // 定义单位
    private static final long KB = 1024;
    private static final long MB = KB * 1024;
    private static final long GB = MB * 1024;

    public static String getAutoFileSize(long length) {
        if (length < KB) {
            return length + " B";
        } else if (length < MB) {
            return String.format("%.2f KB", (double) length / KB);
        } else if (length < GB) {
            return String.format("%.2f MB", (double) length / MB);
        } else {
            return String.format("%.2f GB", (double) length / GB);
        }
    }
}
