在Byte []中创建后检索我的号码 [英] Retrieve my number after make it in Byte[]

查看:149
本文介绍了在Byte []中创建后检索我的号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在Byte []

I want to retrieve a basic number after make it in 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 []?

Retrieve my number after make it in Byte[] ?

推荐答案

我认为你在使用 Byte [] 代替 byte []

    byte[] t = (byte[]) s1.subList(0, 3).toArray();
    System.out.println(convertByteToInt(t));

此外,您可能想要使用 parse()将字符串转换为数字,例如下面:

Also You may want to use parse() to convert string to numbers e.g. below:

    String intString= new String(t); //<--get String from byte array
    int numInt = Integer.parseInt(intString);

这篇关于在Byte []中创建后检索我的号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆