Treeviz 0.37 2010-10-17

ch.randelshofer.util
Class FileSizeFormat

java.lang.Object
  extended by ch.randelshofer.util.FileSizeFormat

public class FileSizeFormat
extends java.lang.Object

Formats units in bytes into a human readable string. FIXME - Rework this, so that we can specify the number of desired digits.

Version:
1.1.1 2010-06-20 Don't scale byte values to kilobytes.
1.1 2009-07-05 By default use megabyte units instead of mebibyte units.
1.0 2009-03-20 Created.
Author:
Werner Randelshofer

Constructor Summary
FileSizeFormat()
           
 
Method Summary
 java.lang.String format(long w)
          Returns a medium version of the formatted string.
static FileSizeFormat getInstance()
           
 boolean isMebibyte()
           
 void setAlwaysIncludeBytes(boolean newValue)
           
 void setMaximumFractionDigits(int newValue)
           
 void setMebibyte(boolean isMebibyte)
           
 void setShortFormat(boolean newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSizeFormat

public FileSizeFormat()
Method Detail

setMaximumFractionDigits

public void setMaximumFractionDigits(int newValue)

setAlwaysIncludeBytes

public void setAlwaysIncludeBytes(boolean newValue)

setShortFormat

public void setShortFormat(boolean newValue)

setMebibyte

public void setMebibyte(boolean isMebibyte)

isMebibyte

public boolean isMebibyte()

format

public java.lang.String format(long w)
Returns a medium version of the formatted string.

Parameters:
w - Units in bytes.
Returns:
Formatted string.

getInstance

public static FileSizeFormat getInstance()

Copyright 2007-2008 (c) Werner Randelshofer.
All rights reserved.