I am trying to reverse the characters in a string separated by a delimiter I provide.
Input: string: "Abc.134dsq"
, delimiter: "."
Desired Output: cbA.qsd431
My attempt:
String fileContent = "Abc.134dsq";
String delimiter = ".";
fileContent = fileContent.replace(delimiter, "-");
String[] splitWords = fileContent.split("-");
StringBuilder stringBuilder = new StringBuilder();
for (String word : splitWords) {
StringBuilder output = new StringBuilder(word).reverse();
stringBuilder.append(output);
}
System.out.println(stringBuilder.toString());
See Question&Answers more detail:os