snowfi6916
snowfi6916

Reputation: 695

Apache Common IO FileUtils Issue

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?

Upvotes: 3

Views: 8284

Answers (2)

snowfi6916
snowfi6916

Reputation: 695

Turns out I was adding the Tomcat library files as well as the JRE library files to my project. Because when I deleted commons-io from my POM, I still had FileUtils available.

I had to get rid of the Tomcat library files from my build path, and once I put commons-io back in, it worked.

Upvotes: 0

Rangel Preis
Rangel Preis

Reputation: 394

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

Upvotes: 5

Related Questions