Java IO读取的文件名中出现特殊字符罗致无法找到文件的处理
Java IO读取的文件名中出现特殊字符导致无法找到文件的处理
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 -->