Memory-mapped files in Java

后端 未结 4 366
长发绾君心
长发绾君心 2020-12-16 03:52

I\'ve been trying to write some very fast Java code that has to do a lot of I/O. I\'m using a memory mapped file that returns a ByteBuffer:

public static Byt         


        
4条回答
  •  抹茶落季
    2020-12-16 04:30

    Wrapping byte[] won't slow things down...there won't be any huge array copies or other little performance evils. From the JavaDocs: java.nio.ByteBuffer .wrap()

    Wraps a byte array into a buffer.

    The new buffer will be backed by the the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be array.length, its position will be zero, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.

提交回复
热议问题