Skip to content

Instantly share code, notes, and snippets.

@dtulig
Created October 11, 2011 03:14
Show Gist options
  • Save dtulig/1277178 to your computer and use it in GitHub Desktop.
Save dtulig/1277178 to your computer and use it in GitHub Desktop.
final String[] input = new String[] {"dave", "john",
null, "dan", null, "matt"};
final String resultSkip = Joiner.on(",")
.skipNulls()
.join(input);
// resultSkip = "dave,john,dan,matt"
final String resultUseForNull = Joiner.on(",")
.useForNull("<blank>")
.join(input);
// resultUseForNull = "dave,john,<blank>,dan,<blank>,matt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment