Java File Size Readable Format formatSize(long v)

Here you can find the source of formatSize(long v)

Description

format Size

License

LGPL

Declaration

public static String formatSize(long v) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static String formatSize(long v) {
        if (v < 1024)
            return v + " B";
        int z = (63 - Long.numberOfLeadingZeros(v)) / 10;
        return String.format("%.1f %sB", (double) v / (1L << (z * 10)), " KMGTPE".charAt(z));
    }/* w  w w .j  a  v  a2s. c  o m*/
}

Related

  1. formatSize(long size)
  2. formatSize(long size)
  3. FormatSize(long size)
  4. formatSize(Long size)
  5. formatSize(long size)
  6. formatSize(String strSize)
  7. formatSize(StringBuilder builder, Long size)
  8. formatSizeInBytes(int size)
  9. formatSpaceUsage(long size)