转换浮动[]为byte []浮动[]再次 [英] Convert float[] to byte[] to float[] again

查看:107
本文介绍了转换浮动[]为byte []浮动[]再次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想在这里做的就是一个浮动[] ,将其转换为字节[] ,通过网络将其作为一个数据报数据包,​​然后将其转换回字节[] 。

So what I'm trying to do here is get a float[], convert it to byte[], send it through the network as a datagram packet and then convert it back to a byte[] at the receiving terminal.

现在我知道我可以转换浮动[] 字节[] 使用的getBytes [] 方法。但我不知道如何扭转转换。

Now I know I can convert float[] to byte[] by using the getBytes[] method. But I don't know how to reverse the conversion.

推荐答案

我想你想使用的ByteBuffer 类,它有的putFloat getFloat 方法。

I think you want to make use of the ByteBuffer class, which has putFloat and getFloat methods.

这篇关于转换浮动[]为byte []浮动[]再次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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