Java HTML Encode toHtmlVerticalString(final String source)

Here you can find the source of toHtmlVerticalString(final String source)

Description

to Html Vertical String

License

Apache License

Declaration

public static String toHtmlVerticalString(final String source) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String toHtmlVerticalString(final String source) {
        if ((source == null) || (source.trim().length() == 0)) {
            return source;
        }//  ww w  .  ja v a2 s . c  om

        final String tmp = source.trim();
        final int len = tmp.length();
        final StringBuffer result = new StringBuffer();

        for (int i = 0; i < (len - 1); i++) {
            result.append(tmp.charAt(i)).append("<br>");
        }

        result.append(tmp.charAt(len - 1));

        return result.toString();
    }

    /**
     * To string.
     *
     * @param obj the obj
     * @return the string
     */
    public static String toString(final Object obj) {
        if (obj == null) {
            return "";
        } else {
            return obj.toString();
        }
    }
}

Related

  1. toHtmlText(String s)
  2. toHtmlText(String text)
  3. toHtmlTitle(final String title)
  4. toHtmlUrl(String url, String displayLabel)
  5. toHtmlValue(String s)