Decode the Morse code
Source
package codewars;
//https://www.codewars.com/kata/54b724efac3d5402db00065e/train/java
public class MorseCodeDecoder{
public static String decode(String morseCode){
StringBuilder sb = new StringBuilder();
String[] word = morseCode.trim().split("\\s{3}");
for(int i = 0; i < word.length; i++){
String[] letter = word[i].split("\\s{1}");
for(int j = 0; j < letter.length; j++){
sb.append(MorseCode.get(letter[j]));
}
if(i != word.length - 1){
sb.append(" ");
}
}
return sb.toString();
}
}