Apache Common IO FileUtils Issue

snowfi6916 picture snowfi6916 · Apr 16, 2013 · Viewed 7.3k times · Source

I am trying to use the FileUtils.writeStringToFile() method of the Apache Commons IO. Every bit of documentation says that I can do this:

FileUtils.writeStringToFile(File, String with data, boolean append);

I want this method, because I want the data to be written to the end of the file each time.

However, in Eclipse, it keeps telling me that this method does not exist. The only two I have are:

FileUtils.writeStringToFile(File, String with data);
FileUtils.writeStringToFile(File, String with data, String encoding);

I corrected my POM file to now have this dependency:

<dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
</dependency>

Can someone please tell me what I am doing wrong?

Answer

Rangel Preis picture Rangel Preis · Apr 16, 2013

Version 1.3.2 doesn't have this method, use a newer version of commons-io

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>

Check the FileUtils 2.4 javadoc