[英]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.