Java tutorial
//package com.java2s; public class Main { public static void appendTextElement(StringBuilder sb, String tagName, String value) { appendTagPre(sb, tagName); sb.append(value); appendTagPost(sb, tagName); } public static void appendTagPre(StringBuilder sb, String tagName) { sb.append("<").append(tagName).append(">"); } public static void appendTagPost(StringBuilder sb, String tagName) { sb.append("</").append(tagName).append(">"); } }