Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** convert given "directiveName" to "directive-name" */ private static String getDirectiveNameAsHtmlAttribute(String directiveName) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < directiveName.length(); i++) { char ch = directiveName.charAt(i); if (Character.isUpperCase(ch)) { sb.append('-'); ch = Character.toLowerCase(ch); } sb.append(ch); } return sb.toString(); } }