Created
August 18, 2020 14:26
-
-
Save parzibyte/6a1e771f00a7b4e4c8df042f56497d44 to your computer and use it in GitHub Desktop.
This file contains 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 binaryToText(String binaryText) { | |
// Necesitamos separar cada número binario por espacio. Usamos split | |
String[] binaryNumbers = binaryText.split(" "); | |
String text = ""; | |
// Los recorremos. En cada paso tenemos al número binario | |
for (String currentBinary : binaryNumbers) { | |
// Ahora convertimos ese binario a decimal | |
int decimal = binaryToDecimal(currentBinary); | |
// Obtenemos la letra que le corresponde a ese valor ASCII | |
char letra = (char) decimal; | |
text += letra; | |
} | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment