Java Byte Array to String bytesToString(long bytes)

Here you can find the source of bytesToString(long bytes)

Description

bytes To String

License

Open Source License

Declaration

public static String bytesToString(long bytes) 

Method Source Code

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

public class Main {
    public static String bytesToString(long bytes) {

        int unit = 1024;
        if (bytes < unit)
            return bytes + " B";
        int exp = (int) (Math.log(bytes) / Math.log(unit));
        String pre = ("KMGTPE").charAt(exp - 1) + "";
        return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
    }/*  w  ww  .j av a2s  .  c  om*/
}

Related

  1. bytesToString(int bytes)
  2. bytesToString(int bytes)
  3. bytesToString(int... bytesInt)
  4. bytesToString(long b)
  5. bytesToString(long bytes)
  6. bytesToString(long size)
  7. byteTo16String(byte[] bt)
  8. byteToMacString(byte[] data)
  9. byteToStr(byte[] byteArray)