Java - Build String by Array Members
//Is used to build string by separate array members
StringBuilder sb = new StringBuilder();
//User choice
if (lineno == 0) {
//Splits text by line breaks
String[] lines = Text.split(System.getProperty("line.separator"));
//Splits lines into words by spec. character - space "\\s"
String[] line = lines[0].split("\\s");
//Loops for each word in line
for(String item : line) {
if(item.indexOf("-") == -1) {
String name = item.toLowerCase();
name = name.substring(0, 1).toUpperCase() + name.substring(1);
name = name.replace(",", "");
sb.append(name);
}
else {
String name = item.toLowerCase();
name = name.substring(0, 1).toUpperCase() + name.substring(1, name.indexOf("-")) + "-" + name.substring(name.indexOf("-") + 1, name.indexOf("-") + 2).toUpperCase() + name.substring(name.indexOf("-") + 2);
name = name.replace(",", "");
sb.append(name);
}
}
}