public class HumanReadableBytes extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HumanReadableBytes.UnitSystem |
| Modifier and Type | Field and Description |
|---|---|
static HumanReadableBytes |
ZERO |
| Constructor and Description |
|---|
HumanReadableBytes(long bytes) |
HumanReadableBytes(String bytes) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object thatObj) |
static String |
format(long bytes,
long precision,
HumanReadableBytes.UnitSystem unitSystem)
Returns a human-readable string version of input value
|
long |
getBytes() |
int |
getBytesInInt() |
int |
hashCode() |
static long |
parse(String number) |
static long |
parse(String number,
long nullValue)
parse the case-insensitive string number, which is either:
|
String |
toString() |
static HumanReadableBytes |
valueOf(int bytes) |
static HumanReadableBytes |
valueOf(long bytes) |
public static final HumanReadableBytes ZERO
public HumanReadableBytes(String bytes)
public HumanReadableBytes(long bytes)
public long getBytes()
public int getBytesInInt()
public static HumanReadableBytes valueOf(int bytes)
public static HumanReadableBytes valueOf(long bytes)
public static long parse(String number)
public static long parse(String number, long nullValue)
a number string
or
a number string with a suffix which indicates the unit the of number the unit must be one of following k - kilobyte = 1000 m - megabyte = 1,000,000 g - gigabyte = 1,000,000,000 t - terabyte = 1,000,000,000,000 p - petabyte = 1,000,000,000,000,000 Ki(B) - kilo binary byte = 1024 Mi(B) - mega binary byte = 1024*1204 Gi(B) - giga binary byte = 1024*1024*1024 Ti(B) - tera binary byte = 1024*1024*1024*1024 Pi(B) - peta binary byte = 1024*1024*1024*1024*1024
nullValue - to be returned when given number is null or emptyIAE - if the input is invalidpublic static String format(long bytes, long precision, HumanReadableBytes.UnitSystem unitSystem)
bytes - input value. Negative value is also allowedprecision - [0,3]unitSystem - which unit system is adopted to format the input value, see HumanReadableBytes.UnitSystemCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.