java FileNotFoundException(文件太大)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25242287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FileNotFoundException (File too large)
提问by Poyraz
I am getting this exception when trying to download a file
尝试下载文件时出现此异常
Caused by: java.io.FileNotFoundException: /repository/PWWVFSYWDW0STLHYVEEKHMYBXZTTETGROCQ4FGdsadadaXR1407709207964905350810526.jpg (File too large)
at java.io.FileOutputStream.open(Native Method)
It is clear that file the exists. In addition to that, the same program works properly on my PC, but there is a problem with the server, which is Unix
很明显,该文件存在。除此之外,同样的程序在我的电脑上正常运行,但是服务器有问题,它是 Unix
Any ideas what might be causing this?
任何想法可能导致这种情况?
回答by Stephen C
I think that this is an obscure error that is actually coming from the OS level or the JVM's native code implementation. The message "File too large" is the error message that you would get if the perror
C library method was used to render the EFBIG
error number.
我认为这是一个模糊的错误,它实际上来自操作系统级别或 JVM 的本机代码实现。如果使用perror
C 库方法来呈现EFBIG
错误编号,则消息“文件太大”是您将获得的错误消息。
Now ordinarily, this should not happen. According to the UNIX / Linux manual entries, the various open
library calls should not fail with EFBIG.
现在通常情况下,这不应该发生。根据 UNIX/Linux 手册条目,各种open
库调用不应因 EFBIG 而失败。
However, I have seen various error reports that imply that fopen
(etcetera) can fail like that on some file systems, and/or when the a C / C++ program has been built with 64bit file size support disabled.
但是,我看到各种错误报告暗示fopen
(等)在某些文件系统上可能会失败,和/或在构建 C/C++ 程序时禁用 64 位文件大小支持。
So what does this mean?
那么这是什么意思?
It is not clear, but I suspect that it means that you are either:
目前尚不清楚,但我怀疑这意味着您是:
using a flaky implementation of Java,
running a flaky release of UNIX / Linux, or
you are trying to use some type of file system that is not well supported by your server's OS. (Might it be on a FUSE file system?)
使用 Java 的片状实现,
运行不稳定的 UNIX/Linux 版本,或
您正在尝试使用服务器操作系统不支持的某种类型的文件系统。(它可能在 FUSE 文件系统上吗?)
A possibly related Java bug:
一个可能相关的 Java 错误:
- http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7009975(Java 7 on Solaris.)
回答by Poyraz
So , it is solved. The problem is that, disk is full as a result stream takes long time, I clean up the disk after that there is no problem,
于是,就解决了。问题是,磁盘已满,因此流需要很长时间,之后我清理磁盘就没有问题了,
回答by duhaime
I received this message when trying to write a file to a directory on a RedHat server that already had the maximum number of files in it. I subdivided my files into subdirectories and the error did not reappear.
我在尝试将文件写入 RedHat 服务器上已拥有最大文件数的目录时收到此消息。我将文件细分到子目录中,错误没有再次出现。
回答by Ali Tofigh
problem:
java.io.FileNotFoundException: /sent/plain/2009/04/Sterling_AS2_to_edt_AS2_Sterling_SJMVM00 A.20090429115945.All_to_cil_QM_214.GS13173.cgs_to_cil.PR120301900.node (File too large)
Files that do not have a very long filename are successfully written out to the same directory.
文件名不是很长的文件会成功写出到同一目录中。
solution:
Reduce the assign filename length or remove older archived files with the longer filenames from that directory and try again.
回答by mgaert
Irrespective of the JVM error output (which might be misleading or slightly off), you may want to check the that your Unix processhas enough open file handles. Exhausting process file handles can lead to all kinds of FS-related error codes.
无论 JVM 错误输出如何(可能会产生误导或略有偏差),您可能需要检查 Unix进程是否有足够的打开文件句柄。耗尽进程文件句柄会导致各种与 FS 相关的错误代码。
回答by Raedwald
POSIX (and thus Unix) systems are allowed to impose a maximum length on the path(what you get from File.getPath()
or the components of a path (the last of which you can get with File.getName()
). You might be seeing this problem because of the long name for the file.
POSIX(以及 Unix)系统被允许在路径上施加最大长度(你从什么File.getPath()
或路径的组成部分(你可以得到的最后一个File.getName()
)。由于长名称,您可能会看到这个问题为文件。
In that case, the file open
operating system call will fail with an ENAMETOOLONG
error code.
在这种情况下,文件open
操作系统调用将失败并显示ENAMETOOLONG
错误代码。
However, the message "File too large" is typically associated with the EFBIG
error code. That is more likely to result from a write
system call:
但是,消息“文件太大”通常与EFBIG
错误代码相关联。这更有可能是由write
系统调用引起的:
An attempt was made to write a file that exceeds the implementation-dependent maximum file size or the process' file size limit.
尝试写入的文件超出了与实现相关的最大文件大小或进程的文件大小限制。
Perhaps the file is being opened for appending, and the implied lseek
to the end of the file is giving the EFBIG
error.
也许文件正在打开以进行追加,并且lseek
文件末尾的隐含信息给出了EFBIG
错误。