DataInputStream上的字节序 [英] Endianness on DataInputStream

查看:153
本文介绍了DataInputStream上的字节序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想要加载的文件格式,其中包含OpenGL对象的原始数据。

I have a file format that I want to load that contains raw data for OpenGL objects.

一切都很好,但数据编码为小端。

All would be well but that data is encoded little endian.

是否有一个java类完成DataInputStream的确切工作但是使用小端或者我必须逐字节加载它并自己执行转换?

Is there a java class that does the exact job of DataInputStream but using little endian or do I have to load it byte by byte and perform the conversions myself?

推荐答案

DataInputStream只是大端。

DataInputStream is only big endian.

如果你使用ByteBuffer你可以改变字节序with

If you use ByteBuffer you can change the endianness with

buffer.order(ByteOrder.LITTLE_ENDIAN);

这篇关于DataInputStream上的字节序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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