Last active
August 17, 2016 08:33
-
-
Save Gounlaf/8cdbcaf3507247e5046c2dfda35c6ee1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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