List of usage examples for java.lang Long toString
public static String toString(long i)
From source file:Main.java
/** * prepare long value used as amount for display * (implicit 2 decimals)/* w w w .j av a 2s . com*/ * @param l value * @param len display len * @return formated field * @exception ISOException */ public static String formatAmount(long l, int len) { String buf = Long.toString(l); if (l < 100) buf = zeropad(buf, 3); StringBuilder s = new StringBuilder(padleft(buf, len - 1, ' ')); s.insert(len - 3, '.'); return s.toString(); }
From source file:Main.java
public static String formatSize(long size) { String suffix = null;//from ww w. java 2 s . c o m if (size >= 1024) { suffix = "KB"; size /= 1024; if (size >= 1024) { suffix = "MB"; size /= 1024; } } StringBuilder resultBuffer = new StringBuilder(Long.toString(size)); int commaOffset = resultBuffer.length() - 3; while (commaOffset > 0) { resultBuffer.insert(commaOffset, ','); commaOffset -= 3; } if (suffix != null) { resultBuffer.append(suffix); } return resultBuffer.toString(); }
From source file:Main.java
public static String trans2FreeAndTotalMem(long[] memInfo) { return Long.toString(memInfo[1] + memInfo[2] + memInfo[3]) + "M/" + Long.toString(memInfo[0]) + "M"; }