Java File Size Readable Format formatSize(double size)

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

Description

format Size

License

Open Source License

Declaration

public static String formatSize(double size) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final String[] SIZE_UNITS = { "B", "K", "M", "G", "T" };

    public static String formatSize(double size) {
        int i;//  www .  j a  v  a2s . c om
        for (i = 0; size >= 1024 && i < 4; i++) {
            size /= 1024;
        }
        return (Math.round(size * 100.0) / 100.0) + " " + SIZE_UNITS[i];
    }
}

Related

  1. formatIndex(int index, int totalSize)
  2. formatInt(int val, int size)
  3. formatRow(String[] values, int[] sizes)
  4. formatSeperatorRow(int[] sizes)
  5. formatShortByte(long size)
  6. formatSize(Integer size)
  7. formatSize(long bytes)
  8. formatSize(long bytes, String b, String kb, String mb, String gb)
  9. formatSize(long size)