public enum SizeUnit extends Enum<SizeUnit>
SizeUnitType.SI
SizeUnitType.NON_SI
SizeUnitType
Enum Constant and Description |
---|
B
Byte or Byte
|
EB
Exabyte or Exbibyte
|
GB
Gigabyte or Gibibyte
|
KB
Kilobyte or Kibibyte
|
MB
Megabyte or Mebibyte
|
PB
Petabyte or Pebibyte
|
TB
Terabyte or Tebibyte
|
YB
Yottabyte or Yobibyte
|
ZB
Zettabyte or Zebibyte
|
Modifier and Type | Method and Description |
---|---|
String |
getString()
get unit, by type that insert
|
String |
getString(SizeUnitType type)
get string of specify input type
|
SizeUnitType |
getType() |
static void |
main(String[] args)
Example usage directly
otherwise you can use this enum by SizeUtil.getSize(long, SizeUnit, SizeUnitType) |
SizeUnit |
setType(SizeUnitType type)
set new type and return this
|
BigDecimal |
to(BigDecimal number,
int decimalPoint,
SizeUnit unit)
convert this unit to any unit that you pass from the parameter
and return the decimal number in decimal point number Example: decimalPoint=2 the return value will compute until 2 number after pass dot (##.XX) |
BigDecimal |
to(BigDecimal number,
SizeUnit unit)
same with
to(BigDecimal, int, SizeUnit) but pass int as Size.SIZE_SCALE |
BigDecimal |
toB(BigDecimal number)
toB(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toB(BigDecimal number,
int decimalPoint)
|
BigDecimal |
toE(BigDecimal number)
toE(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toE(BigDecimal number,
int decimalPoint)
convert this unit to EB unit (
EB ) 1 EB = 1,000,000,000,000,000,000 byte or 1,152,921,504,606,846,976 byte Minimum: 10^18 or 2^60 |
BigDecimal |
toG(BigDecimal number)
toG(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toG(BigDecimal number,
int decimalPoint)
convert this unit to GB unit (
GB ) 1 GB = 1,000,000,000 byte or 1,073,741,824 byte Minimum: 10^9 or 2^30 |
BigDecimal |
toK(BigDecimal number)
toK(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toK(BigDecimal number,
int decimalPoint)
|
BigDecimal |
toM(BigDecimal number)
toM(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toM(BigDecimal number,
int decimalPoint)
|
BigDecimal |
toP(BigDecimal number)
toP(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toP(BigDecimal number,
int decimalPoint)
convert this unit to PB unit (
PB ) 1 PB = 1,000,000,000,000,000 byte or 1,125,899,906,842,624 byte Minimum: 10^15 or 2^50 |
BigDecimal |
toT(BigDecimal number)
toT(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toT(BigDecimal number,
int decimalPoint)
convert this unit to TB unit (
TB ) 1 TB = 1,000,000,000,000 byte or 1,099,511,627,776 byte Minimum: 10^12 or 2^40 |
BigDecimal |
toY(BigDecimal number)
toY(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toY(BigDecimal number,
int decimalPoint)
convert this unit to YB unit (
YB ) 1 YB = 1,000,000,000,000,000,000,000,000 byte or 1,208,925,819,614,629,174,706,176 byte Minimum: 10^24 or 2^80 |
BigDecimal |
toZ(BigDecimal number)
toZ(BigDecimal, int) by place int to Size.SIZE_SCALE |
BigDecimal |
toZ(BigDecimal number,
int decimalPoint)
convert this unit to ZB unit (
ZB ) 1 ZB = 1,000,000,000,000,000,000,000 byte or 1,180,591,620,717,411,303,424 byte Minimum: 10^21 or 2^70 |
static SizeUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SizeUnit |
valueOf(String s,
SizeUnitType type)
get string that must contain unit of file size and convert it to
SizeUnit |
static SizeUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SizeUnit B
public static final SizeUnit KB
public static final SizeUnit MB
public static final SizeUnit GB
public static final SizeUnit TB
public static final SizeUnit PB
public static final SizeUnit EB
public static final SizeUnit ZB
public static final SizeUnit YB
public static SizeUnit[] values()
for (SizeUnit c : SizeUnit.values()) System.out.println(c);
public static SizeUnit 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 SizeUnit setType(SizeUnitType type)
type
- the new type, can't be null
public SizeUnitType getType()
public String getString()
public String getString(SizeUnitType type)
type
- input size unit typepublic static SizeUnit valueOf(String s, SizeUnitType type)
SizeUnit
s
- string that contains unit, like this SizeUtil.toMinimumByte(long, SizeUnitType)
methodtype
- the type (can be null if don't know)B
public BigDecimal toB(BigDecimal number, int decimalPoint)
number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toB(BigDecimal)
method instantlypublic BigDecimal toK(BigDecimal number, int decimalPoint)
number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toK(BigDecimal)
method instantlypublic BigDecimal toM(BigDecimal number, int decimalPoint)
number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toM(BigDecimal)
method instantlypublic BigDecimal toG(BigDecimal number, int decimalPoint)
GB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toG(BigDecimal)
method instantlypublic BigDecimal toT(BigDecimal number, int decimalPoint)
TB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toT(BigDecimal)
method instantlypublic BigDecimal toP(BigDecimal number, int decimalPoint)
PB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toP(BigDecimal)
method instantlypublic BigDecimal toE(BigDecimal number, int decimalPoint)
EB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toE(BigDecimal)
method instantlypublic BigDecimal toZ(BigDecimal number, int decimalPoint)
ZB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toZ(BigDecimal)
method instantlypublic BigDecimal toY(BigDecimal number, int decimalPoint)
YB
) number
- the number to conversiondecimalPoint
- the decimal to conversion, if you want to use Size.SIZE_SCALE
yo can call toY(BigDecimal)
method instantlypublic BigDecimal toB(BigDecimal number)
toB(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toK(BigDecimal number)
toK(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toM(BigDecimal number)
toM(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toG(BigDecimal number)
toG(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toT(BigDecimal number)
toT(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toP(BigDecimal number)
toP(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toE(BigDecimal number)
toE(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toZ(BigDecimal number)
toZ(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal toY(BigDecimal number)
toY(BigDecimal, int)
by place int to Size.SIZE_SCALE
number
- the conversion numberpublic BigDecimal to(BigDecimal number, int decimalPoint, SizeUnit unit)
number
- the conversion numberdecimalPoint
- the number of number after dot (###.XX)unit
- the unit that want to convert topublic BigDecimal to(BigDecimal number, SizeUnit unit)
to(BigDecimal, int, SizeUnit)
but pass int as Size.SIZE_SCALE
number
- the conversion numberunit
- the unit that want to convert topublic static void main(String[] args)
SizeUtil.getSize(long, SizeUnit, SizeUnitType)
Copyright © 2017. All rights reserved.