简体   繁体   English

我想将字符串和整数转换为无符号字节

[英]i want to convert string and integer to unsigned byte

In java i have two variables 在java中我有两个变量

String string;
int integerValue;

I want to convert these values to unsignedbyte that is How to convert string to UnsignedByte and integer to UnsignedByte 我想将这些值转换为unsignedbyte,即如何将字符串转换为UnsignedByte,如何将整数转换为UnsignedByte

Java does not have an unsigned byte. Java没有无符号字节。

Converting from String to short is done by Short.parseShort(string) 从String转换为short是通过Short.parseShort(string)

If you are referring to Axis's UnsignedByte class, you can use the constructors: 如果要引用Axis的UnsignedByte类,则可以使用构造函数:

new UnsignedByte(sting);
new UnsignedByte(integerValue);

Java没有像无符号字节那样的类型,您必须为此使用更大的short(对于unsigned int,它必须是long)。

short s = (short) integerValue;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将表示整数的字符串转换为Java中的无符号字节数组? - How to convert A string that represents an integer to unsigned byte array in Java? Java将无符号大整数转换为无符号字节 - Java convert unsigned big integer to unsigned byte 使用java或android将整数转换为无符号字节数组 - Convert integer to unsigned byte array with java or android 使用ByteBuffer将long转换为“无符号,网络字节顺序为4字节整数” - Convert long to “unsigned, 4 byte integer in network byte order” with ByteBuffer 对于我的项目,我想将一个整数转换为字节数组,将字节数组转换回整数 - For my project I want to convert an integer into byte array and byte array back to integer 如何将整数转换为无符号的32位大字节序字节数组 - How do I convert an integer to unsigned 32 bit big endian byte array 在Java中将十六进制字符串转换为无符号字节数组 - Convert Hex String to unsigned Byte Array in Java 如何在Java中将字节数组转换为无符号的128位整数? - How to convert byte array to unsigned 128 bit integer in Java? 将无符号字节转换为有符号字节 - Convert unsigned byte to signed byte Java - 想要将整数值类型转换为字节,以便我可以以二进制格式写入文件 - Java - Want to convert an Integer Value type to a Byte, so I can write to a file in binary format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM