PandacraftUtils/src/net/mc_pandacraft/java/util/MemoryUtil.java
2014-11-22 17:18:10 +01:00

26 lines
547 B
Java

package net.mc_pandacraft.java.util;
import java.text.DecimalFormat;
public class MemoryUtil {
public static String humanReadableSize(long octet)
{
DecimalFormat format = new DecimalFormat("#####0.00");
double size = octet;
if (size < 1024)
return size+"o";
size /= 1024;
if (size < 1024)
return format.format(size)+"kio";
size /= 1024;
if (size < 1024)
return format.format(size)+"Mio";
size /= 1024;
if (size < 1024)
return format.format(size)+"Gio";
size /= 1024;
return format.format(size)+"Tio";
}
}