Java Size Format formatFilesizeGB(long filesize, int fractionDigits)

Here you can find the source of formatFilesizeGB(long filesize, int fractionDigits)

Description

Formats filesize in bytes to GB

License

Open Source License

Parameter

Parameter Description
filesize in bytes
fractionDigits ...

Return

formatted filesize

Declaration

private static String formatFilesizeGB(long filesize, int fractionDigits) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.text.NumberFormat;

public class Main {
    /** static number format instance. Used to format filesizes. */
    private static NumberFormat numberFormat = NumberFormat.getInstance();

    /** Formats filesize in bytes to GB
     *//from  www.  j a  va2s .  co  m
     * @param filesize in bytes
     * @param fractionDigits ...
     * @return formatted filesize
     */
    private static String formatFilesizeGB(long filesize, int fractionDigits) {
        numberFormat.setMaximumFractionDigits(fractionDigits);

        // 1048576 = 1024.0 * 1024.0
        return new StringBuffer(numberFormat.format(filesize / 1073741824.0)).append(" GB").toString();
    }
}

Related

  1. formatFileSize(long size)
  2. formatFileSize(long size)
  3. formatFileSize(long size)
  4. formatFileSize(long size)
  5. formatFileSize(Long sizeBytes)
  6. formatGameSize(int size)
  7. formatMemorySize(long size)
  8. formatPartSize(int size, NumberFormat format)
  9. formatSize(double fileSize)