Android机子的文件夹下有存放文件的个数限制,做了下测试,如下:
在创建第65534个文件时抛出了异常:
java.io.IOException: open failed: ENOSPC (No space left on device) at java.io.File.createNewFile(File.java:940) at lab.sodino.filenumbertest.MainActivity$2.run(MainActivity.java:50) Caused by: libcore.io.ErrnoException: open failed: ENOSPC (No space left on device) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110) at java.io.File.createNewFile(File.java:933) ... 1 more
见下图: 要注意做好清理工作,虽然...这种事情出现的概率很小,但还是被碰到了,瀑布汗...