class ByteFormat extends Format {

    /**
     * Formats a long which represent a number of bytes.
     * @param bytes the number of bytes to format
     * @return the formatted string
     */
    public String format(long bytes) {
        return super.format(bytes);
    }

    /**
     * Formats a long which represent a number of kilobytes.
     * @param kilobytes the number of kilobytes to format
     * @return the formatted string
     */
    public String formatKB(long kilobytes) {
        return format(kilobytes * 1024);
    }

    /**
     * Format the given object (must be a Long).
     *
     * @param obj assumed to be the number of bytes as a Long.
     * @param buf the StringBuffer to append to.
     * @param pos the field position
     * @return A formatted string representing the given bytes in more human-readable form.
     */
    @Override
    public StringBuffer format(Object obj, StringBuffer buf, FieldPosition pos) {<FILL_FUNCTION_BODY>}

    /**
     * In this implementation, returns null always.
     *
     * @param source unused parameter
     * @param pos unused parameter
     * @return returns null in this implementation.
     */
    @Override
    public Object parseObject(String source, ParsePosition pos) {
        return null;
    }
}

        if (obj instanceof Long) {
            long numBytes = (Long) obj;
            if (numBytes < 1024 * 1024) {
                DecimalFormat formatter = new DecimalFormat("#,##0.0");
                buf.append(formatter.format((double)numBytes / 1024.0)).append(" K");
            }
            else {
                DecimalFormat formatter = new DecimalFormat("#,##0.0");
                buf.append(formatter.format((double)numBytes / (1024.0 * 1024.0))).append(" MB");
            }
        }
        return buf;
    
<methods>public java.lang.Object clone() ,public final java.lang.String format(java.lang.Object) ,public abstract java.lang.StringBuffer format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) ,public java.text.AttributedCharacterIterator formatToCharacterIterator(java.lang.Object) ,public java.lang.Object parseObject(java.lang.String) throws java.text.ParseException,public abstract java.lang.Object parseObject(java.lang.String, java.text.ParsePosition) <variables>private static final long serialVersionUID