Why RandomAccessFile uses int as an offset

I am writing some implementation of a data access test, and I need random access to the contents of the file. Here is the code:

RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rwd");
final byte b[] = IOUtils.toByteArray(source);
randomAccessFile.write(b, (int) offset, size);

where offset is of type long. Why does the RandomAccessFile method not provide a method:

public void write(byte b[], long off, int len)

?

How to override this problem?

+3
source share
1 answer

I think you are looking for a method seek.

The offset in writeis the offset in the array. Arrays have offsets int. There were suggestions for "long arrays", but if they were implemented, you still need overload.

NIO , MappedByteBuffer.position - int. . CR 6347833 (9 ).

+15

Source: https://habr.com/ru/post/1731410/


All Articles