public static enum Storage.Unit extends Enum<Storage.Unit>
| Enum Constant and Description |
|---|
b
Storage unit size of one bit.
|
B
Storage unit size of one byte.
|
Gb
Storage unit size of one giga-bit.
|
GB
Storage unit size of one giga-byte.
|
Kb
Storage unit size of one kilo-bit.
|
KB
Storage unit size of one kilo-byte.
|
Mb
Storage unit size of one mega-bit.
|
MB
Storage unit size of one mega-byte.
|
Pb
Storage unit size of one peta-bit.
|
PB
Storage unit size of one peta-byte.
|
Tb
Storage unit size of one tera-bit.
|
TB
Storage unit size of one tera-byte.
|
| Modifier and Type | Field and Description |
|---|---|
long |
bits
Amount of bits represented by this storage unit.
|
float |
bytes
Amount of bytes (
bits / 8) represented by this storage unit. |
String |
fullName
Full name of this storage unit.
|
| Modifier and Type | Method and Description |
|---|---|
float |
formatBits(long bits)
Formats the given amount of bits to format specific for this storage unit.
|
float |
formatBytes(long bytes)
Formats the given amount of bytes to format specific for this storage unit.
|
static Storage.Unit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Storage.Unit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Storage.Unit b
public static final Storage.Unit B
public static final Storage.Unit Kb
public static final Storage.Unit KB
public static final Storage.Unit Mb
public static final Storage.Unit MB
public static final Storage.Unit Gb
public static final Storage.Unit GB
public static final Storage.Unit Tb
public static final Storage.Unit TB
public static final Storage.Unit Pb
public static final Storage.Unit PB
public final String fullName
public final long bits
public final float bytes
bits / 8) represented by this storage unit.public static Storage.Unit[] values()
for (Storage.Unit c : Storage.Unit.values()) System.out.println(c);
public static Storage.Unit 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 float formatBits(long bits)
For example, Unit.MB.formatBits(8388608) will result in 1 which
can be printed as 1 MB.
bits - The amount of bits to format to this storage unit's representative value.formatBytes(long)public float formatBytes(long bytes)
For example, Unit.MB.formatBytes(1048576) will result in 1 which
can be printed as 1 MB.
bytes - The amount of bytes to format to this storage unit's representative value.formatBits(long)