简体   繁体   中英

Using Netbeans 8.0.2 and want to use org.apache.commons.io.FileUtils; how?

Specifically I want to use the FileUtils.contentEquals(file1, file2) method.

I've downloaded and extracted files to C:\\Users\\Dov\\commons-io-2.4-bin\\commons-io-2.4 .

I added exactly that pathname to my Netbeans project Librairies folder but of course import org.apache.commons.io.FileUtils; didn't compile.

What will make the program below compile?

import java.io.File;
import java.io.IOException;
import static org.apache.commons.io.FileUtils.contentEquals;

public class CompareFileContents {

    public static void main(String[] args) throws IOException {

        File file1 = new File("C:\\Users\\Dov\\Docs\\desktop.ini");
        File file2 = new File("C:\\Users\\Dov\\Documents\\desktop.ini");

        System.out.println("test1.txt and test2.txt are the same: " +
                           contentEquals(file1, file2));
    }
}

Right click on your project

Properties - Library - Compile tab - Add Jar/Folder and select the .jar File

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM