public enum DataUnit extends Enum<DataUnit>
此类来自于:Spring-framework
BYTES 1B 2^0 1
KILOBYTES 1KB 2^10 1,024
MEGABYTES 1MB 2^20 1,048,576
GIGABYTES 1GB 2^30 1,073,741,824
TERABYTES 1TB 2^40 1,099,511,627,776
| Enum Constant and Description |
|---|
BYTES
Bytes, 后缀表示为:
B. |
GIGABYTES
Gigabytes, 后缀表示为:
GB. |
KILOBYTES
Kilobytes, 后缀表示为:
KB. |
MEGABYTES
Megabytes, 后缀表示为:
MB. |
TERABYTES
Terabytes, 后缀表示为:
TB. |
| Modifier and Type | Field and Description |
|---|---|
static String[] |
UNIT_NAMES
单位名称列表
|
static String[] |
UNIT_NAMES_SIMPLE
单位名称列表(简写)
|
| Modifier and Type | Method and Description |
|---|---|
static DataUnit |
fromSuffix(String suffix)
通过后缀返回对应的 DataUnit
|
String |
getSuffix()
单位后缀
|
static DataUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DataUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DataUnit BYTES
B.public static final DataUnit KILOBYTES
KB.public static final DataUnit MEGABYTES
MB.public static final DataUnit GIGABYTES
GB.public static final DataUnit TERABYTES
TB.public static final String[] UNIT_NAMES
public static final String[] UNIT_NAMES_SIMPLE
public static DataUnit[] values()
for (DataUnit c : DataUnit.values()) System.out.println(c);
public static DataUnit valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String getSuffix()
public static DataUnit fromSuffix(String suffix)
suffix - 单位后缀DataUnitIllegalArgumentException - 后缀无法识别报错Copyright © 2025. All rights reserved.