Here you can find the source of getStringSize(String string)
public static final float getStringSize(String string)
//package com.java2s; /**//from ww w . j av a 2 s.c om * Converts a line of text into an array of lower case words using a * BreakIterator.wordInstance(). * <p> * <p/> * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text * a String of text to convert into an array of words * @return text broken up into an array of words. */ import java.text.DecimalFormat; public class Main { public static final float getStringSize(String string) { float size = 0f; if (string.length() > 0) { size = string.length() / 1024f; } size = size * 100; if (size > (int) size) { size = size + 1; } size = size / 100f; DecimalFormat format = new DecimalFormat("##.##"); return Float.parseFloat(format.format(size)); } }