java – Remove Minecraft formatting codes from a String

I obtain strings that contain chat messages, and they sometimes have formatting codes imbedded in them. A formatting code is a § followed by a character, and this character then defines how the code will affect the following text. Colour codes can occur at the very end of the String, a common case of a message would be:

"§r§aThis is a message.§r§bAnd this is blue...§r"

Currently I’m using this method, which simply iterates over the String and skips another character when it encounters a §. Is this a good solution, and how can I further improve it?

private String cleanFormattingCodes(String message) {
    StringBuilder newMessage = new StringBuilder();
    for (int i = 0; i < message.length(); i++) {
      char c = message.charAt(i);
      if (c == '§') {

    return newMessage.toString();