Here you can find the source of formatFilesizeGB(long filesize, int fractionDigits)
Parameter | Description |
---|---|
filesize | in bytes |
fractionDigits | ... |
private static String formatFilesizeGB(long filesize, int fractionDigits)
//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(); } }