Java Memory memoryValue(long inBytes)

Here you can find the source of memoryValue(long inBytes)

Description

memory Value

License

Open Source License

Declaration

@Deprecated
    public static String memoryValue(long inBytes) 

Method Source Code

//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;
    }
}

Related

  1. memoryInfo()
  2. memoryIsLow()
  3. memoryOccupied()
  4. memorySize(long bytesSize)
  5. memoryUtilization()
  6. normalizeMemoryMeasure(String memory)
  7. percentMemoryFull()
  8. removeSliceFromMemory(String schemaName, String cubeName, String loadName)
  9. reportMemory()