Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 21, 2020 18:57

Revisions

  1. parzibyte created this gist Aug 21, 2020.
    10 changes: 10 additions & 0 deletions textToBinary.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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;
    }