Java Utililty Methods String Format

List of utility methods to do String Format

Description

The list of methods to do String Format are organized into topic(s).

Method

StringformatStringTo80Columns(String str)
Takes a string and formats it so that words are not cut off at the 80 column mark.
ArrayList<String> list = new ArrayList<String>();
String[] split = str.split(" ");
StringBuffer buffer = new StringBuffer();
for (int count = 0; count < split.length; count++) {
    String word = split[count];
    if ((buffer.length() + word.length() + 1) > 80) {
        list.add(buffer.toString());
        buffer = new StringBuffer(word);
...
ListformatTooltip(String tooltip)
format Tooltip
return formatTooltip(tooltip, 45);
StringformatTreeLines(String tree)
format Tree Lines
if (tree == null || tree.equals(""))
    return tree;
StringBuilder reconstructedTree = new StringBuilder();
boolean isOpen = false;
for (String s : tree.split(LINE_SEPARATOR)) {
    List<Integer> insStartIndexes = getIndexesOf(s, "<ins>");
    List<Integer> insEndIndexes = getIndexesOf(s, "</ins>");
    List<Integer> delStartIndexes = getIndexesOf(s, "<del>");
...
voidformatVarname(StringBuilder buffer, Object varname)
format Varname
if (varname instanceof String)
    buffer.append((String) varname);
else {
    List varnames = (List) varname;
    buffer.append("(");
    int count = 0;
    for (Object subvarname : varnames) {
        ++count;
...
StringformatWords(String words, String delimiter, boolean isHeaderUpperCase)
Formats a string list of words delimited to a camel forat: XxxxXxxxXxxx or xxxxXxxxXxxx
if (isNullOrEmpty(words)) {
    return words;
List<String> listWords = parseStringList(words, delimiter);
return formatWords(listWords, isHeaderUpperCase);
StringgetAnswerKey(String itemFormat)
get Answer Key
List formats = Arrays.asList("EBSR", "EQ", "NL", "SA", "ER", "GI", "HT", "MI", "TI", "WER", "WORDLIST",
        "TUT", "SIM", "PASS");
if (formats.contains(itemFormat)) {
    return itemFormat;
} else {
    return null;
StringgetCodeFileName(String fileNameFormat, String randomCode)
get Code File Name
return MessageFormat.format(fileNameFormat, randomCode);
ListgetDBPediaFormatDescriptions(String descriptionStr)
get DB Pedia Format Descriptions
List<String> descriptions = new ArrayList<String>();
if (descriptionStr != null && descriptionStr.length() > 0) {
    descriptions.add(descriptionStr);
return descriptions;
StringgetEmailFormatError(String fieldPropertyName)
get Email Format Error
return getPropertyText(fieldPropertyName) + " is not a well-formed email address";
StringgetFormat(String key, ResourceBundle bundle)
Get the format string associated with key in the given resource bundle.
String fmt = "no text found: \"" + key + "\" {0}";
if (bundle != null) {
    try {
        fmt = bundle.getString(key);
    } catch (MissingResourceException e) {
return fmt;
...