    public static String addCommas(String orig) {
        StringBuffer buf = new StringBuffer(orig);
        int len = orig.length();
        buf.ensureCapacity(len + (len - 1) / 3);

        for (int pos = len - 3; pos > 0; pos -= 3)
            buf.insert(pos, ',');
        return buf.toString();
    }
