Utils.java Source code

Java tutorial

Introduction

Here is the source code for Utils.java

Source

/**
 * @author matthew_hicks
 */
public class Utils {

    public static final String breakLinesHTML(String s, int width) {
        if (s == null)
            return null;

        StringBuffer buffer = new StringBuffer();
        buffer.append("<html><body><font face=\"Arial\" size=\"-1\">");
        int p = 0;
        char c;
        for (int i = 0; i < s.length(); i++) {
            c = s.charAt(i);
            if (((p >= width) && (c == ' ')) || (c == '\n')) {
                buffer.append("<br>");
                p = 0;
            } else {
                buffer.append(c);
            }
            p++;
        }
        buffer.append("</font></body></html>");
        return buffer.toString();
    }

}