public class ByteFormatter
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
byteSuffix |
private java.lang.String |
gigabyteSuffix |
private java.lang.String |
kilobyteSuffix |
private static org.apache.commons.logging.Log |
log |
private java.lang.String |
megabyteSuffix |
private javax.swing.text.NumberFormatter |
nf |
| Constructor and Description |
|---|
ByteFormatter()
Constructs a formatter that will use default text to represent byte amounts.
|
ByteFormatter(java.lang.String gigabyteSuffix,
java.lang.String megabyteSuffix,
java.lang.String kilobyteSuffix,
java.lang.String byteSuffix,
int decimalPlaces)
Constructs a formatter that will use the given values when formatting byte values.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
formatByteSize(long byteSize)
Converts a byte size into a human-readable string, such as "1.43 MB" or "27 KB".
|
private static final org.apache.commons.logging.Log log
private java.lang.String gigabyteSuffix
private java.lang.String megabyteSuffix
private java.lang.String kilobyteSuffix
private java.lang.String byteSuffix
private javax.swing.text.NumberFormatter nf
public ByteFormatter()
public ByteFormatter(java.lang.String gigabyteSuffix,
java.lang.String megabyteSuffix,
java.lang.String kilobyteSuffix,
java.lang.String byteSuffix,
int decimalPlaces)
gigabyteSuffix - string to display at the end of gigabyte values.megabyteSuffix - string to display at the end of megabyte values.kilobyteSuffix - string to display at the end of kilobyte values.byteSuffix - string to display at the end of byte values.decimalPlaces - the number of decimal places to use when converting byte amounts into kilo, mega or giga
byte values.public java.lang.String formatByteSize(long byteSize)
byteSize - the byte size of some item