
Tiny, fluent DSL handling byte quantities with binary (KiB/MiB…) and decimal (KB/MB…) units, inline StorageSize type with arithmetic, comparisons, and Path size converters.
Tiny, fluent Kotlin DSL for working with byte counts using binary (IEC) and decimal units.
StorageSize value type with arithmetic and comparisons.KiB, MiB, …) and decimal (KB, MB, …) extensions on Int/Long.Path sizes (toStorageSize()).dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
}
}dependencies {
implementation("io.github.czoeller:kbytes:1.0.0-SNAPSHOT")
}For snapshots, add the Central Portal snapshots repository:
repositories {
maven {
name = "Central Portal Snapshots"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
content {
includeModule("io.github.czoeller", "kbytes")
}
}
mavenCentral()
}Replace 1.0.0-SNAPSHOT with the version you want.
val size = 3.GB + 512.MB // arithmetic
println(size.bestDecimalUnit()) // Sized(value=3.512, unit=GB)
val fileSize = somePath.toStorageSize()
println(fileSize.inBytes())Tiny, fluent Kotlin DSL for working with byte counts using binary (IEC) and decimal units.
StorageSize value type with arithmetic and comparisons.KiB, MiB, …) and decimal (KB, MB, …) extensions on Int/Long.Path sizes (toStorageSize()).dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
}
}dependencies {
implementation("io.github.czoeller:kbytes:1.0.0-SNAPSHOT")
}For snapshots, add the Central Portal snapshots repository:
repositories {
maven {
name = "Central Portal Snapshots"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
content {
includeModule("io.github.czoeller", "kbytes")
}
}
mavenCentral()
}Replace 1.0.0-SNAPSHOT with the version you want.
val size = 3.GB + 512.MB // arithmetic
println(size.bestDecimalUnit()) // Sized(value=3.512, unit=GB)
val fileSize = somePath.toStorageSize()
println(fileSize.inBytes())