Class StorageUnitConverter

  • public class StorageUnitConverter
    extends Object
    • Constructor Detail

      • StorageUnitConverter

        public StorageUnitConverter()
    • Method Detail

      • byteCountToDisplaySize

        public String byteCountToDisplaySize​(long byteCount)
        Converts byte count to the human readable representation. The size is rounded to nearest X-byte.

        For example: 13.1MB in byte count will return 13MB and 13.9MB in byte count wil return 13MB.

        Supported types: EB, PB, TB, GB, MB, KB or B (for bytes).

        byteCount -
        human reabable display size
      • displaySizeToByteCount

        public long displaySizeToByteCount​(String displaySize)
        Convert human human readable file size format to byte equivalent.

        Accepted units:

        • B - Bytes
        • KB - Kilobytes
        • MB - Megabytes
        • GB - Gigabytes
        Example display sizes:
        displaySize - human readable size format
        total number of bytes