首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java IO读取的文件名中出现特殊字符罗致无法找到文件的处理

2012-12-24 
Java IO读取的文件名中出现特殊字符导致无法找到文件的处理File classDir new File(train_dir,CATEGORIE

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 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 -->取自“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”<!-- end content -->

热点排行