Skip to content

Instantly share code, notes, and snippets.

@Gounlaf
Last active August 17, 2016 08:33
Show Gist options
  • Save Gounlaf/8cdbcaf3507247e5046c2dfda35c6ee1 to your computer and use it in GitHub Desktop.
Save Gounlaf/8cdbcaf3507247e5046c2dfda35c6ee1 to your computer and use it in GitHub Desktop.
public static String stringToHardcodedCharArray(@NotNull String s) {
char[] chars = s.toCharArray();
StringBuilder output = new StringBuilder("char[] key = {");
if (chars.length > 0) {
output.append("'").append(chars[0]).append("'");
for (int i = 1; i < chars.length; i++) {
output.append(",'").append(chars[i]).append("'");
}
}
return output.append("};").toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment