【问题标题】:FileNotFoundException while creating a file with java in Ubuntu?在 Ubuntu 中使用 java 创建文件时出现 FileNotFoundException?
【发布时间】:2013-05-17 01:18:21
【问题描述】:

我一直在尝试将数百万个 xml 文档转换为 txt 文件。读取每个 xml 后,我会解析所需的内容并将其写入新目录中的新文本文件中。

但是当我处理大量文件(例如超过 7000 个)时,我得到了 FileNotFoundException。

这是堆栈跟踪:

java.io.FileNotFoundException: /media/volume/data/File8838.txt (Input/output error)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at com.infoarmy.ir.ml.FormatData.main(FormatData.java:126)

FormatData的代码sn-p是:

File newFile = new File("/media/volume/data/File8838.txt");
newFile.getParentFile().mkdirs();
BufferedWriter writer = new BufferedWriter(new FileWriter(newFile));
writer.write(builder.toString());
writer.close();

奇怪的是: 发生此异常后,我也无法使用 vi 创建文件。错误 212

谁能指出为什么会这样?

【问题讨论】:

  • 可能是你没有权限
  • 可能是你的新卷没有挂载?
  • 正确的错误是Input/output error 堆栈跟踪显示
  • 看看这个问题,可能会有帮助:stackoverflow.com/questions/8253362/…
  • 您有可用的磁盘空间吗?

标签: java file unix ubuntu filenotfoundexception


【解决方案1】:

试试

writer.flush()

关闭之前

【讨论】:

  • 打开文件时出现问题。 -1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-25
  • 1970-01-01
  • 2012-05-30
  • 2021-02-10
  • 2023-04-03
  • 1970-01-01
相关资源
最近更新 更多