Java IO读取的文件名中出现特殊字符导致无法找到文件的处理
File classDir = new File(train_dir,CATEGORIES);String[] trainingFiles = classDir.list();
File file = new File(classDir,trainingFiles);
GetHtmlText getText= new GetHtmlText(file.toURI().toASCIIString());
一定要 file.toURI().toASCIIString() 否则 文件名中有 ? 等字符,则 可能找不到文件。或者使用 file.toURI().getRawPath()
<!-- NewPP limit reportPreprocessor node count: 1/1000000Post-expand include size: 0/2097152 bytesTemplate argument size: 0/2097152 bytesExpensive 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 --><div class="printfooter">取自“http://wisdombase.net/wiki/index.php?title=Java_%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E4%B8%AD%E7%89%B9%E6%AE%8A%E7%AC%A6%E5%8F%B7%E9%97%AE%E9%A2%98”
页:
[1]