public final class FileSizeCalcer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FileSizeCalcer.CalcFactor
This enumeration defines the devision factors used by the FileSizeCalcer.
|
static class |
FileSizeCalcer.FileSize
This enumeration defines the file size exponents of the CalcFactor to calculate file sizes.
|
Modifier and Type | Method and Description |
---|---|
static long |
getBytes(double value,
FileSizeCalcer.CalcFactor factor,
FileSizeCalcer.FileSize unit)
Gets the size in bytes.
|
static long |
getBytesFromKB(double kb)
Converts KB to bytes with a factor of 1024.
|
static long |
getBytesFromMB(double mb)
Converts MB to bytes with a factor of 1024.
|
static double |
getGB(long bytes)
Calculates the file size in GigaByte of the given bytes.
|
static double |
getKB(long bytes)
Calculates the file size in KiloByte of the given bytes.
|
static double |
getMB(long bytes)
Calculates the file size in MegaByte of the given bytes.
|
static String |
getNiceSize(long bytes,
FileSizeCalcer.CalcFactor calcFactor)
Computes the size using the specified factor and automatically adds the proper unit (B, KB or
KiB, MB or MiB, GB or GiB, PB or PiB).
|
static double |
getPB(long bytes)
Calculates the file size in PetaByte of the given bytes.
|
static double |
getSize(long bytes,
FileSizeCalcer.CalcFactor factor,
FileSizeCalcer.FileSize size)
Returns the size according to the given parameters.
|
static double |
getTB(long bytes)
Calculates the file size in TeraByte of the given bytes.
|
public static double getSize(long bytes, FileSizeCalcer.CalcFactor factor, FileSizeCalcer.FileSize size)
bytes
- The number of bytes.factor
- The factor to be used to calculate the size (KIBI_FACTOR(1024) or
KILO_FACTOR(1000)).size
- The desired file size.public static double getKB(long bytes)
bytes
- The number of bytes.public static double getMB(long bytes)
bytes
- The number of bytes.public static double getGB(long bytes)
bytes
- The number of bytes.public static double getTB(long bytes)
bytes
- The number of bytes.public static double getPB(long bytes)
bytes
- The number of bytes.public static long getBytesFromMB(double mb)
mb
- size in MBpublic static long getBytesFromKB(double kb)
kb
- size in KBpublic static long getBytes(double value, FileSizeCalcer.CalcFactor factor, FileSizeCalcer.FileSize unit)
value
- the value of the file sizefactor
- the factor to calculate withunit
- the size unit of the file sizepublic static String getNiceSize(long bytes, FileSizeCalcer.CalcFactor calcFactor)
bytes
- size in bytescalcFactor
- the factor to use when calculating the size (1024 or 1000)Copyright © 2020 Hyland Software Germany GmbH. All rights reserved.