convert little Endian file into big Endian

后端 未结 6 897
感动是毒
感动是毒 2020-12-04 01:23

how can i convert a liitle Endian binary file into big Endian binary file. i have a binary binary written in C and i am reading this file in Java with DataInputStream which

6条回答
  •  Happy的楠姐
    2020-12-04 02:21

    You can use EndianUtils from Apache Commons I/O:

    It has static methods like long readSwappedLong(InputStream input) that can do all the swapping for you. It also has overloads that uses a byte[] as input, as well as write counterpart (to OutputStream or byte[]). It also has non-I/O methods like int swapInteger(int value) methods that can do conversion of plain Java primitives.

    The package also has many useful utility classes like FilenameUtils, IOUtils, etc.

    See also

    • Most useful free third party Java libraries?

提交回复
热议问题