com.atlassian.core.util
Class FileSize
java.lang.Object
com.atlassian.core.util.FileSize
public class FileSize
- extends Object
A class that contains utility methods for formatting the size of files into human
readable form.
|
Method Summary |
static String |
format(long filesize)
Format the size of a file in human readable form. |
static String |
format(Long filesize)
Convenience method. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileSize
public FileSize()
format
public static String format(Long filesize)
- Convenience method. Calls format(long filesize).
- Parameters:
filesize - The size of the file in bytes.
- Returns:
- The size in human readable form.
- See Also:
format(long)
format
public static String format(long filesize)
- Format the size of a file in human readable form. Anything less than a kilobyte
is presented in kilobytes to one decimal place. Anything between a kilobyte and a megabyte is
presented in kilobytes to zero decimal places. Anything greater than one megabyte is
presented in megabytes to two decimal places.
eg.
- format(512) -> 0.5 kb
- format(1024) -> 1.0 kb
- format(2048) -> 2 kb
- format(1024 * 400) -> 400 kb
- format(1024 * 1024) -> 1024 kb
- format(1024 * 1024 * 1.2) -> 1.20 Mb
- format(1024 * 1024 * 20) -> 20.00 Mb
- Parameters:
filesize - The size of the file in bytes.
- Returns:
- The size in human readable form.
Copyright © 2015 Atlassian. All rights reserved.