How to convert a binary representation of a string into byte in Java?(如何在Java中将字符串的二进制表示转换为字节?)
问题描述
正如标题所说,我该怎么做?它很容易从字符串 -> 字节 -> 字符串二进制转换,但是我如何转换回来?下面是一个例子.输出是:'f' 到二进制:01100110294984
我在某处读到可以使用 Integer.parseInt 但显然不是这样 :( 还是我做错了什么?
谢谢,:)
as the title says, how do I do it? Its easy to convert from string -> byte -> string binary, But how do I convert back? Below is a example. The output is : 'f' to binary: 01100110 294984
I read somewhere that I could use the Integer.parseInt but clearly that is not the case :( Or am I doing something wrong?
Thanks, :)
You can use Byte.parseByte()
with a radix of 2:
Using your example:
102
这篇关于如何在Java中将字符串的二进制表示转换为字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!