请教android文件操作-too many open files

wer_second 2012-01-07 01:26:29
主要代码如下:

File file1 = new File(path1);
if(!file1.exists())
{
file1.createNewFile();
}
FileOutputStream fos1 = new FileOutputStream(file1);
DataOutputStream dos1 = new DataOutputStream(fos1);

for(int i=0;i<nCount;i++) //nCount = 10;
{
dos1.write(something);

for(int n=0;n<nSizeX;n++) //nSizeX = 30;
{
for(int m=0;m<nSizeY;m++) //nSizeY = 30;
{
dos1.write(something);

File file2 = new File(path2);
if(!file2.exists())
{
file2.createNewFile();
}

FileOutputStream fos2 = new FileOutputStream(file2);
DataOutputStream dos2 = new DataOutputStream(fos2);

dos2.write(something);

dos2.close();
fos2.close();
}
}
}

dos1.close();
fos1.close();

明明都close了,为什么还会报错:too many open files?又该如何修改呢?谢谢。
...全文
400 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧