Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 18, 2020 14:26
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/6a1e771f00a7b4e4c8df042f56497d44 to your computer and use it in GitHub Desktop.
Save parzibyte/6a1e771f00a7b4e4c8df042f56497d44 to your computer and use it in GitHub Desktop.
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