我想在 Byte[] 中获取一个基本数字
public static void main(String[] args) throws IOException {
LinkedList<Byte> s1 = new LinkedList<Byte>();
String a = "0.111112345";
for (byte bb : a.getBytes()) {
s1.add(bb);
}
//how to retrieve "0.111112345"; from s1 ?
在 Byte[] 中输入号码后检索我的号码?
最佳答案
我认为您正在使用 Byte[]
代替 byte[]
:
byte[] t = (byte[]) s1.subList(0, 3).toArray();
System.out.println(convertByteToInt(t));
此外,您可能希望使用 parse()
将字符串转换为数字,例如下面:
String intString= new String(t); //<--get String from byte array
int numInt = Integer.parseInt(intString);
关于java - 在 Byte[] 中输入后检索我的号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13089764/