Here you can find the source of formatPair(double in, double out)
private static String formatPair(double in, double out)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { static final String THINSP = " / "; /**/*from w w w . j a va2s . c om*/ * @return "x.xx / y.yy {K|M}" */ private static String formatPair(double in, double out) { boolean mega = in >= 1024 * 1024 || out >= 1024 * 1024; // scale both the same if (mega) { in /= 1024 * 1024; out /= 1024 * 1024; } else { in /= 1024; out /= 1024; } // control total width DecimalFormat fmt; if (in >= 1000 || out >= 1000) fmt = new DecimalFormat("#0"); else if (in >= 100 || out >= 100) fmt = new DecimalFormat("#0.0"); else fmt = new DecimalFormat("#0.00"); return fmt.format(in) + THINSP + fmt.format(out) + " " + (mega ? 'M' : 'K'); } }