Jump to content
LaunchBox Community Forums

java code to convert binary to text


bryanvieta

Recommended Posts

hello all,

my client wants me to add a binary to text conversion on my app. I am not an experience developer and I was really bad at this kind of number conversions in my college. Is there any code to convert binary to text in java? any reference to this conversion will be appreciated.?

Link to comment
Share on other sites

Javascript:

const password = "TestPw";

password
    .split('') 
    .map(letter => letter.charCodeAt() 
                     .toString(2) 
    ) 
    .join(' ');

Java:(I copied this code, I'm not sure about this)

public static String toText(String info)throws UnsupportedEncodingException{
        byte[] encoded = info.getBytes();
        String text = new String(encoded, "UTF-8");
        System.out.println("print: "+text);
        return text;
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...