Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 21, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/fe3dd8b74deedb625586d32970308a04 to your computer and use it in GitHub Desktop.
Save parzibyte/fe3dd8b74deedb625586d32970308a04 to your computer and use it in GitHub Desktop.
public static String textToBinary(String originalText) {
String binaryText = "";
for (int i = 0; i < originalText.length(); i++) {
char currentChar = originalText.charAt(i);
int ascii = (int) currentChar;
String binary = decimalToBinary(ascii);
binaryText += binary + " ";
}
return binaryText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment