Skip navigation links

Package com.jakewharton.byteunits

Utility classes for converting between granularities of SI (power-of-ten) and IEC (power-of-two) byte units and bit units.

See: Description

Package com.jakewharton.byteunits Description

Utility classes for converting between granularities of SI (power-of-ten) and IEC (power-of-two) byte units and bit units.

Example Usage

What's the difference in hard drive space between perception and actual?

 long perception = DecimalByteUnit.TERABYTES.toBytes(2);
 long usable = BinaryByteUnit.TEBIBYTES.toBytes(2);
 long lost = BinaryByteUnit.BYTES.toGibibytes(perception - usable);
 System.out.println(lost + " GiB lost on a 2TB drive.");
 

Method parameter for specifying a resource size.


 public void installDiskCache(long count, ByteUnit unit) {
   long size = unit.toBytes(count);
   // TODO Install disk cache of 'size' bytes.
 }
 
Skip navigation links

Copyright © 2014. All Rights Reserved.