public enum DataUnit extends Enum<DataUnit>
DataSize
units.
The unit prefixes used in this class are binary prefixes indicating multiplication by powers of 2. The following table displays the enum constants defined in this class and corresponding values.
Constant | Data Size | Power of 2 | Size in Bytes |
---|---|---|---|
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 |
DataSize
Enum Constant and Description |
---|
BYTES
Bytes, represented by suffix
B . |
GIGABYTES
Gigabytes, represented by suffix
GB . |
KILOBYTES
Kilobytes, represented by suffix
KB . |
MEGABYTES
Megabytes, represented by suffix
MB . |
TERABYTES
Terabytes, represented by suffix
TB . |
Modifier and Type | Method and Description |
---|---|
static DataUnit |
fromSuffix(String suffix)
Return the
DataUnit matching the specified suffix . |
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 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 static DataUnit fromSuffix(String suffix)
DataUnit
matching the specified suffix
.suffix
- one of the standard suffixesDataUnit
matching the specified suffix
IllegalArgumentException
- if the suffix does not match the suffix
of any of this enum's constants