File classDir = new File(train_dir,CATEGORIES[i]);
String[] trainingFiles = classDir.list();
File file = new File(classDir,trainingFiles[j]);
GetHtmlText getText= new GetHtmlText(file.toURI().toASCIIString());
一定要 file.toURI().toASCIIString() 否则 文件名中有 ? 等字符,则 可能找不到文件。或者使用 file.toURI().getRawPath()
<!-- NewPP limit report Preprocessor node count: 1/1000000 Post-expand include size: 0/2097152 bytes Template argument size: 0/2097152 bytes Expensive parser function count: 0/100 --><!-- Saved in parser cache with key knowledg_wikidb:pcache:idhash:58-0!1!0!!zh-cn!2!edit=0 and timestamp 20110526023442 --> <!-- end content -->
本文介绍了在Java中处理文件路径时遇到特殊字符的问题及解决方案。通过使用file.toURI().toASCIIString()或file.toURI().getRawPath()方法,可以有效解决文件名中含有特殊字符导致的文件无法找到的问题。
1342

被折叠的 条评论
为什么被折叠?



