gpt4 book ai didi

Java - HtmlUnit - 无法将 HTML 保存到文件(在某些情况下)

转载 作者:行者123 更新时间:2023-12-01 16:05:41 25 4
gpt4 key购买 nike

我在 HtmlUnit 中保存响应 HTML 时遇到间歇性问题。

Caused by: java.io.IOException: Unable to save file:C:\ccview\PP50773_4.0_walter\TSC_hca\Applications\HCA_J2EE\HCA\target\HtmlUnitTests\single\1\com\pnc\tsc\hca\ui\test\SiteCrawler\crawlSiteAsProvider\10.SiteCrawler.crawl.html
at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:128)
at com.pnc.tsc.hca.ui.util.GetUtil.add(GetUtil.java:75)
at com.pnc.tsc.hca.ui.util.GetUtil.click(GetUtil.java:49)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:87)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:61)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:54)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawlSiteAsProvider(SiteCrawler.java:50)
... 15 more
Caused by: java.lang.RuntimeException: java.io.IOException: The system cannot find the path specified
at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:165)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printOpeningTag(XmlSerializer.java:126)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:83)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.asXml(XmlSerializer.java:73)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.save(XmlSerializer.java:55)
at com.gargoylesoftware.htmlunit.html.HtmlPage.save(HtmlPage.java:2259)
at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:126)
... 24 more
Caused by: java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.createFile(XmlSerializer.java:216)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:160)
... 32 more

现在,父目录已存在,并且其他一些文件已写入该目录。查看文件名,我没有看到任何明显的危险信号,表明文件名是错误的。

我可以做什么来纠正这个错误?

谢谢

沃尔特

最佳答案

嗯,您完全在最大路径长度之内。异常跟踪显然认为这是路径问题。

我会尝试一些额外的测试来帮助隔离问题。在写入之前检查目录:File.exists()、File.isDirectory()、File.isWritable()。对文件本身进行类似的检查。可能想看看磁盘是否已满。

如果您能获得有关问题根源的更多信息,我们就能解决问题。

关于Java - HtmlUnit - 无法将 HTML 保存到文件(在某些情况下),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2692082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com