bytesize

A simple Java utility for formatting and parsing data sizes.

Лицензия

Лицензия

Группа

Группа

org.codeswarm
Идентификатор

Идентификатор

bytesize
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

bytesize
A simple Java utility for formatting and parsing data sizes.
Ссылка на сайт

Ссылка на сайт

https://github.com/codeswarm/bytesize
Система контроля версий

Система контроля версий

https://github.com/codeswarm/bytesize

Скачать bytesize

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.codeswarm/bytesize/ -->
<dependency>
    <groupId>org.codeswarm</groupId>
    <artifactId>bytesize</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.codeswarm/bytesize/
implementation 'org.codeswarm:bytesize:1.0'
// https://jarcasting.com/artifacts/org.codeswarm/bytesize/
implementation ("org.codeswarm:bytesize:1.0")
'org.codeswarm:bytesize:jar:1.0'
<dependency org="org.codeswarm" name="bytesize" rev="1.0">
  <artifact name="bytesize" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.codeswarm', module='bytesize', version='1.0')
)
libraryDependencies += "org.codeswarm" % "bytesize" % "1.0"
[org.codeswarm/bytesize "1.0"]

Зависимости

test (1)

Идентификатор библиотеки Тип Версия
org.testng : testng jar 6.2.1

Модули Проекта

Данный проект не имеет модулей.

bytesize

A Java utility for dealing with data sizes. Supports internationalized formatting and parsing.

Example usage

import org.codeswarm.bytesize.*;

public class ByteSizeDemo {

  public static void main(String[] args) throws java.text.ParseException {

    // Create a new byte size format using the default locale and settings.
    ByteSizeFormat format = new ByteSizeFormatBuilder().build();

    // Parse a byte size string.
    ByteSize a = format.parse(".85 gigabytes");

    // Convert 0.85 gigabytes to megabytes. Prints "850.0".
    System.out.println(a.numberOfBytes(ByteSizeUnits.MB));

    // Create a ByteSize object representing 1500 bytes.
    ExactByteSize b = ByteSizes.byteSize(1500);

    // Get the number of bytes. Prints "1500".
    System.out.println(b.numberOfBytes());

    // Format the size using abbreviated units. Prints "1.5 kB".
    System.out.println(format.format(b, ByteSizeFormat.WordLength.ABBREVIATION));

    // Create a new formatter for the Slovak language using IEC units (powers of 2)
    ByteSizeFormat format2 = new ByteSizeFormatBuilder()
      .unitSystem(ByteSizeUnits.IEC)
      .locale(java.util.Locale.forLanguageTag("sk"))
      .build();

    // Format the first size using full words.
    // Prints "810,623 mebibajtov" (810.623 mebibytes).
    System.out.println(format2.format(a, ByteSizeFormat.WordLength.FULL));

  }

}

Download

Bytesize is available from Maven Central. The latest version is 1.0.

<dependency>
  <groupId>org.codeswarm</groupId>
  <artifactId>bytesize</artifactId>
  <version>1.0</version>
</dependency>

Language support

  • English
  • Slovak
  • Esperanto

If your language is missing from this list, please leave us a note in the issue tracker.

org.codeswarm

Codeswarm

Версии библиотеки

Версия
1.0