java - Convert binary string to ascii text? -


I was wondering if it is possible to enter a binary number and translate them back into text. For example, 01101000 01100101 01101100 01101100 01101111 "and will make it secret in the word" hello ".

Just a few logical corrections:

Here are three steps < Ol>

  • Change the binary set to an integer
  • then the integer in a character
  • then insert the string you are creating

    Fortunately a radix takes for the parseInt basis. Therefore, once you cut an array of substrings necessary to reach string up (perhaps) length 8, or , then you only need to do this (char) Integer .parseInt (S, 2) and concatenate.

      string s2 = ""; For the next four (int i = 0; i & lt; = s.length () - 8; i + = 9) // It is a bit tricky that we want [0, 7], [9, 16] e.t.c. (If the bytes are delimited by increment index 9) {nextChar = (char) Integer.parseInt (s.sstring (i, i + 8), 2); S2 + = nextChar; }    

  • Comments

    Popular posts from this blog

    qt - switch/case statement in C++ with a QString type -

    python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

    Python's equivalent for Ruby's define_method? -