Java tutorial
//package com.java2s; public class Main { /** * Convert the specified DOCTYPE attributes into a DOCTYPE string. * * @param name The DOCTYPE name. * @param publicId The public id of the DOCTYPE. * @param systemId The system id of the DOCTYPE. * @return */ public static String toDTDString(String name, String publicId, String systemId) { StringBuilder dtdBuilder = new StringBuilder(); dtdBuilder.append("<!DOCTYPE "); dtdBuilder.append(name); if (publicId != null) { dtdBuilder.append(" PUBLIC "); dtdBuilder.append('"'); dtdBuilder.append(publicId); dtdBuilder.append('"'); } if (systemId != null) { dtdBuilder.append(' '); dtdBuilder.append('"'); dtdBuilder.append(systemId); dtdBuilder.append('"'); } dtdBuilder.append(">\n"); return dtdBuilder.toString(); } }