Parsing of binary data with scala

前端 未结 5 2051
野趣味
野趣味 2020-12-15 23:38

I need to parse some simple binary Files. (The files contains n entries which consists of several signed/unsigned Integers of different sizes etc.)

In the moment i d

5条回答
  •  一个人的身影
    2020-12-16 00:26

    I don't know what you mean with "by hand" but using a simple DataInputStream (apidoc here) is quite concise and clear:

    val dis = new DataInputStream(yourSource)
    
    dis.readFloat()
    dis.readDouble()
    dis.readInt()
    // and so on
    

    Taken from another SO question: http://preon.sourceforge.net/, it should be a framework to do binary encoding/decoding.. see if it has the capabilities you need

提交回复
热议问题