Java Size Format formatSize(double size)

Here you can find the source of formatSize(double size)

Description

Format as a size

License

Open Source License

Parameter

Parameter Description
size the value to format

Return

the formatted value

Declaration

static public String formatSize(double size) 

Method Source Code

//package com.java2s;
/**//from w w  w . ja  va2  s  .  c  o  m
 * * $Id: Utils.java 28 2005-06-20 13:13:35Z rej $
 * * Copyright (c) 2002 Sun Microsystems, Inc.
 * *
 * * See the file "license.terms" for information on usage and redistribution
 * * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 **/

import java.text.NumberFormat;

public class Main {
    static private NumberFormat longSizeFormatter;
    static private NumberFormat doubleSizeFormatter;

    /**
     * Format as a size
     * @param size the value to format
     * @return the formatted value
     */
    static public String formatSize(long size) {
        return longSizeFormatter.format(size);
    }

    /**
     * Format as a size
     * @param size the value to format
     * @return the formatted value
     */
    static public String formatSize(double size) {
        return doubleSizeFormatter.format(size);
    }
}

Related

  1. formatFilesizeGB(long filesize, int fractionDigits)
  2. formatGameSize(int size)
  3. formatMemorySize(long size)
  4. formatPartSize(int size, NumberFormat format)
  5. formatSize(double fileSize)
  6. formatSize(int size)
  7. formatSize(long bytes)
  8. formatSize(long bytes)
  9. formatSize(long bytes)