String (@NotNull CharSequence chars) { StringBuilder replacement = new StringBuilder(); for (int i = 0; i < chars.length(); i ++) { char c = chars.charAt(i); replacement.append(c == ' ' || c == '\n' || c == '\r' ? c : '*'); } return replacement.toString(); }