org.jivesoftware.util
Class ByteFormat
java.lang.Object
java.text.Format
org.jivesoftware.util.ByteFormat
- All Implemented Interfaces:
- Serializable, Cloneable
public class ByteFormat
- extends Format
A formatter for formatting byte sizes. For example, formatting 12345 byes results in
"12.1 K" and 1234567 results in "1.18 MB".
- Author:
- Bill Lynch
- See Also:
- Serialized Form
ByteFormat
public ByteFormat()
format
public String format(long bytes)
- Formats a long which represent a number of bytes.
formatKB
public String formatKB(long kilobytes)
- Formats a long which represent a number of kilobytes.
format
public StringBuffer format(Object obj,
StringBuffer buf,
FieldPosition pos)
- Format the given object (must be a Long).
- Specified by:
format
in class Format
- Parameters:
obj
- assumed to be the number of bytes as a Long.buf
- the StringBuffer to append to.pos
-
- Returns:
- A formatted string representing the given bytes in more human-readable form.
parseObject
public Object parseObject(String source,
ParsePosition pos)
- In this implementation, returns null always.
- Specified by:
parseObject
in class Format
- Parameters:
source
- pos
-
- Returns:
- returns null in this implementation.
Copyright © 2003-2007 Jive Software.