![](/img/trans.png)
[英]Does RandomAccessFile.read() from local file guarantee that exact number of bytes will be read?
[英]How to read a “long” number of bytes from file with RandomAccessFile in java
我正在嘗試從文件中的某個點讀取文件一定數量的字節。
RandomAccessFile randomAccessFile = new RandomAccessFile(_file, "r"); randomAccessFile.seek(_offSet);
randomAccessFile.read(buffer, 0, _size);
_offSet和_size類型為“ long”的地方。
問題是,讀取方法僅采用“ int”。 我通過使用“搜索”克服了偏移問題,如何克服要讀取的字節數?
我嘗試一次讀取2 GB以上的內存(簡單性除外)沒有任何優勢。您可以使用多個調用讀取2 GB以上的內存。
你會讀到哪里? 無論如何,您不能聲明那么大的數組。 您的問題不存在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.