Class SizeUtils
java.lang.Object
dev.sympho.modular_commands.utils.SizeUtils
Utilities for working with file sizes.
Note the possibility of integer overflow depending on the data type used.
- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(@org.checkerframework.common.value.qual.IntRange(from=0L) long size) Formats a size to the nearest (supported) prefix.static intgiga(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2L) int size) Makes a size in gigabytes.static longgiga(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036L) long size) Makes a size in gigabytes.static intkilo(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2147483L) int size) Makes a size in kilobytes.static longkilo(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036854775L) long size) Makes a size in kilobytes.static intmega(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2147L) int size) Makes a size in megabytes.static longmega(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036854L) long size) Makes a size in megabytes.static longtera(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372L) long size) Makes a size in terabytes.
-
Field Details
-
KILO
public static final int KILOThe value of the K prefix.- See Also:
-
MEGA
public static final int MEGAThe value of the M prefix.- See Also:
-
GIGA
public static final int GIGAThe value of the G prefix.- See Also:
-
TERA
public static final long TERAThe value of the T prefix.- See Also:
-
-
Method Details
-
kilo
public static int kilo(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2147483L) int size) Makes a size in kilobytes.- Parameters:
size- The size in KB.- Returns:
- The size in bytes.
-
kilo
public static long kilo(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036854775L) long size) Makes a size in kilobytes.- Parameters:
size- The size in KB.- Returns:
- The size in bytes.
-
mega
public static int mega(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2147L) int size) Makes a size in megabytes.- Parameters:
size- The size in MB.- Returns:
- The size in bytes.
-
mega
public static long mega(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036854L) long size) Makes a size in megabytes.- Parameters:
size- The size in MB.- Returns:
- The size in bytes.
-
giga
public static int giga(@org.checkerframework.common.value.qual.IntRange(from=0L, to=2L) int size) Makes a size in gigabytes.- Parameters:
size- The size in GB.- Returns:
- The size in bytes.
-
giga
public static long giga(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372036L) long size) Makes a size in gigabytes.- Parameters:
size- The size in GB.- Returns:
- The size in bytes.
-
tera
public static long tera(@org.checkerframework.common.value.qual.IntRange(from=0L, to=9223372L) long size) Makes a size in terabytes.- Parameters:
size- The size in TB.- Returns:
- The size in bytes.
-
format
Formats a size to the nearest (supported) prefix.- Parameters:
size- The size to format.- Returns:
- The formatted size.
-