bryanvieta Posted January 1, 2021 Share Posted January 1, 2021 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.? Quote Link to comment Share on other sites More sharing options...
aaron_smith4 Posted January 1, 2021 Share Posted January 1, 2021 With java, i expect the code would be a bit lengthy. Can you use Javascript in your app? Quote Link to comment Share on other sites More sharing options...
bryanvieta Posted January 1, 2021 Author Share Posted January 1, 2021 i think using js is possible, i really appreciate it! Quote Link to comment Share on other sites More sharing options...
aaron_smith4 Posted January 1, 2021 Share Posted January 1, 2021 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; } Quote Link to comment Share on other sites More sharing options...
bryanvieta Posted January 1, 2021 Author Share Posted January 1, 2021 i used parseInt in that java code and it is working fine only for maximum of sixteen characters. for example, if i insert more then sixteen characters then this tool does return the correct ans. Quote Link to comment Share on other sites More sharing options...
aaron_smith4 Posted January 2, 2021 Share Posted January 2, 2021 Biginteger or bignumber might work well. They are using it and when you enter more then 16 characters, the tool is returning correct answer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.