Apache Common IO FileUtils问题

sno*_*916 3 apache apache-commons fileutils

我正在尝试使用Apache Commons IO的FileUtils.writeStringToFile()方法.每一份文档都说我可以这样做:

FileUtils.writeStringToFile(File, String with data, boolean append);
Run Code Online (Sandbox Code Playgroud)

我想要这种方法,因为我希望每次都将数据写入文件的末尾.

但是,在Eclipse中,它一直告诉我这个方法不存在.我唯一的两个是:

FileUtils.writeStringToFile(File, String with data);
FileUtils.writeStringToFile(File, String with data, String encoding);
Run Code Online (Sandbox Code Playgroud)

我纠正了我的POM文件,现在有这种依赖:

<dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我我做错了什么吗?

Ran*_*eis 5

版本1.3.2没有这种方法,使用较新版本的commons-io

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

检查FileUtils 2.4 javadoc