java.io.RandomAccessFile 对于 Mac 上的大文件无效参数
我正在运行一个程序,需要随机访问一个非常大的文件(大约 151 GB)。我发现每当它在 Orchard 实验室的一台 MacPro 机器上运行时(详细信息请参见 http://inst.eecs.berkeley.edu/cgi-bin/clients.cgi?choice=6a&string= ),程序尝试读取的特定部分文件并因文件系统错误而崩溃:
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(RandomAccessFile.java:322)
我只是使用 RandomAccessFile 类。
RandomAccessFile fd;
//...Initialized and already used fd with
//no problems for larger locations as well
//location == 155587178230
//numBytes == 15492560
//off == 0
//arr.length == 15492560
fd.seek(location);
fd.read(arr, off, numBytes);
无论我使用哪一台 Orchard 实验室计算机,它每次都会在相同的确切位置、相同的字节范围内发生。
我已经在运行 Debian Linux 的 DELL 计算机上测试了此代码,并且没有遇到此问题。
I'm running a program which needs random access to a very large file (approximately 151 gigabytes). I've found that whenever it runs on one of the MacPro machines in the Orchard lab ( details at http://inst.eecs.berkeley.edu/cgi-bin/clients.cgi?choice=6a&string= ), the program tries to read a specific part of the file and crashes with an error from the file system:
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(RandomAccessFile.java:322)
I'm just using the RandomAccessFile class.
RandomAccessFile fd;
//...Initialized and already used fd with
//no problems for larger locations as well
//location == 155587178230
//numBytes == 15492560
//off == 0
//arr.length == 15492560
fd.seek(location);
fd.read(arr, off, numBytes);
It happens in the same exact place for the same exact range of bytes every time no matter which of the Orchard lab computers I use.
I've tested this code on DELL computers running Debian Linux and not had this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 Linux 命令“dd”来检查文件在给定位置是否确实可读。我假设该文件位于 MAC 实验室的网络驱动器上,如果您在 Dell Linux 工作站上访问该文件的副本,则不会收到此错误,因为 DELL 磁盘没有损坏。
You should use the linux command "dd" to check if the file is really readable at the given location. I assume the file is on a network drive in the MAC lab, and if you access your copy of the file on the Dell linux workstation you won't get this error because DELLs disks are not broken.