×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Luis Mata
Added: May 11, 2020 10:10 AM
Views: 4330
Tags: no tags
  1.     public static String humanReadableByteCountBin(long bytes) {
  2.         log.info("Inicia procesamiento de rdirectorios y archivos");
  3.         long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);
  4.         CharacterIterator ci = new StringCharacterIterator(strPattern);
  5.         long value = absB;
  6.  
  7.         if (absB < 1024) {
  8.             return bytes + strByte;
  9.         }
  10.  
  11.         for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) {
  12.             value >>= 10;
  13.             ci.next();
  14.         }
  15.  
  16.         value *= Long.signum(bytes);
  17.  
  18.         log.info("Termina procesamiento de directorios y archivos");
  19.         return String.format("%.1f %ciB", value / 1024.0, ci.current());
  20.     }