Here you can find the source of memoryValue(long inBytes)
@Deprecated public static String memoryValue(long inBytes)
//package com.java2s; public class Main { private static final long kKilobyte = 1024; private static final long kMegabyte = 1024 * kKilobyte; private static final long kGigabyte = 1024 * kMegabyte; private static final long kTerabyte = 1024 * kGigabyte; private static final long kPetabyte = 1024 * kTerabyte; private static final long kExabyte = 1024 * kPetabyte; @Deprecated public static String memoryValue(long inBytes) { return byteCountValue(inBytes); }//from w ww . ja va 2s. co m public static String byteCountValue(long inBytes) { String result = "" + inBytes + " bytes"; if (inBytes > kExabyte) { double d = inBytes / kExabyte; result = "" + d + " EB"; } else if (inBytes > kPetabyte) { double d = inBytes / kPetabyte; result = "" + d + " PB"; } else if (inBytes > kTerabyte) { double d = inBytes / kTerabyte; result = "" + d + " TB"; } else if (inBytes > kGigabyte) { double d = inBytes / kGigabyte; result = "" + d + " GB"; } else if (inBytes > kMegabyte) { double d = inBytes / kMegabyte; result = "" + d + " MB"; } else if (inBytes > kKilobyte) { double d = inBytes / kKilobyte; result = "" + d + " KB"; } return result; } }