import java.util.Objects;
...
sb.append(Objects.toString(s, ""));
Uses Java internal utils, no external libs are needed. toString
takes String, checks if it is null
and if it is null
, then returns specified default value, in this case ""
(empty string), if it is not null
it returns provided string.