Package com.helger.commons.io.misc
Class SizeHelper
java.lang.Object
com.helger.commons.io.misc.SizeHelper
A utility class that converts sizes into the corresponding Kilobyte, Megabyte
etc. notation.
This class is not thread-safe, because the
This class is not thread-safe, because the
DecimalFormat class is not
thread-safe!- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAsGB(long nSize) getAsGB(long nSize, int nDecimals) getAsKB(long nSize) getAsKB(long nSize, int nDecimals) getAsMatching(long nSize) getAsMatching(long nSize, int nDecimals) getAsMatching(BigDecimal aSize) Get the best matching formatting of the passed value.getAsMatching(BigDecimal aSize, int nDecimals) Get the best matching formatting of the passed value.getAsMatching(BigInteger aSize) Get the best matching formatting of the passed value.getAsMatching(BigInteger aSize, int nDecimals) Get the best matching formatting of the passed value.getAsMB(long nSize) getAsMB(long nSize, int nDecimals) getAsPB(long nSize) getAsPB(long nSize, int nDecimals) getAsTB(long nSize) getAsTB(long nSize, int nDecimals) static SizeHelpergetSizeHelperOfLocale(Locale aDisplayLocale) Get the size helper for the passed locale.toString()
-
Field Details
-
B_SUFFIX
Suffix for Bytes- See Also:
-
KB_SUFFIX
Suffix for Kilobytes- See Also:
-
MB_SUFFIX
Suffix for Megabytes- See Also:
-
GB_SUFFIX
Suffix for Gigabytes- See Also:
-
TB_SUFFIX
Suffix for Terabytes- See Also:
-
PB_SUFFIX
Suffix for Petabytes- See Also:
-
-
Constructor Details
-
SizeHelper
-
SizeHelper
-
-
Method Details
-
getAsKB
-
getAsKB
-
getAsMB
-
getAsMB
-
getAsGB
-
getAsGB
-
getAsTB
-
getAsTB
-
getAsPB
-
getAsPB
-
getAsMatching
Get the best matching formatting of the passed value. No fraction digits will be emitted.- Parameters:
aSize- The value to be converted to a size value. May not benull.- Returns:
- The string representation
- Throws:
IllegalArgumentException- If the passed value cannot be fit in a long
-
getAsMatching
Get the best matching formatting of the passed value.- Parameters:
aSize- The value to be converted to a size value. May not benull.nDecimals- The number of fraction digits.- Returns:
- The string representation
- Throws:
IllegalArgumentException- If the passed value cannot be fit in a long
-
getAsMatching
Get the best matching formatting of the passed value. No fraction digits will be emitted.- Parameters:
aSize- The value to be converted to a size value. May not benull.- Returns:
- The string representation
- Throws:
IllegalArgumentException- If the passed value cannot be fit in a long
-
getAsMatching
Get the best matching formatting of the passed value.- Parameters:
aSize- The value to be converted to a size value. May not benull.nDecimals- The number of fraction digits.- Returns:
- The string representation
- Throws:
IllegalArgumentException- If the passed value cannot be fit in a long
-
getAsMatching
-
getAsMatching
-
toString
-
getSizeHelperOfLocale
Get the size helper for the passed locale. The locale determines the formatting of the numeric value.- Parameters:
aDisplayLocale- The locale to be used.- Returns:
- The non-
nullSizeHelperobject for the passed locale.
-