private String reformatHeaderForCsv(final String s) {
        final StringBuilder sb = new StringBuilder(s.length());
        boolean enableComma = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (Character.isWhitespace(c)) {
                if (enableComma) {
                    enableComma = false;
                    sb.append(',');
                }
            } else {
                enableComma = true;
                if (Character.isUpperCase(c)) {
                    c = Character.toLowerCase(c);
                }
                sb.append(c);
            }
        }
        return sb.toString();
    }
Reformats the header inserting commas and removing spaces

@param s a valid string
@return a header suitable for a CSV file.
src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFile.java