有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用ant task native2ascii

我想把一个。txt文件,其中包含与其等效的java unicode值对应的重音字符。Soí被转换为\u00ED

文件名叫做转换。txt 下面是我如何尝试使用蚂蚁目标-

<target name="EncodeFile" >
<native2ascii encoding="ISO8859_1" src="C:\Projects\encodingfiles" 
    dest="C:\Projects\encodingfiles"
    includes="C:\Projects\encodingfiles" ext=".txt" />
</target> 

ant目标运行时不会出错,但不会发生转换

谢谢你的帮助


共 (1) 个答案

  1. # 1 楼答案

    您已经从^{} task文档中为includes指定了一个目录:

    includes comma- or space-separated list of patterns of files that must be included. All files are included when omitted.

    您需要为文件指定模式,或者为要转换的文件指定确切名称。 完整的故事见Directory-based Tasks

    另一件需要注意的事情是,如果srcdest是相同的,并且您想要转换.txt文件,那么指定ext=".txt"将不起作用。这是因为Ant将确定,由于源文件名和目标文件名相同,因此该文件本身是最新的,并跳过它。 如果需要覆盖原始文件,请使用备用dest,然后将转换后的文件复制回src以覆盖

    (经常跑步

    ant -verbose
    

    可以帮助你更多地了解蚂蚁为什么什么都没做。)