简体   繁体   English

使用Netbeans 8.0.2,并希望使用org.apache.commons.io.FileUtils; 怎么样?

[英]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. 具体来说,我想使用FileUtils.contentEquals(file1, file2)方法。

I've downloaded and extracted files to C:\\Users\\Dov\\commons-io-2.4-bin\\commons-io-2.4 . 我已经将文件下载并解压缩到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; 我将那个路径名准确地添加到了Netbeans项目的Librairies文件夹中,但是当然要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 属性-库-编译选项卡-添加Jar /文件夹,然后选择.jar文件

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Servlet中改善org.apache.commons.io.FileUtils copyInputStreamToFile - How to improve org.apache.commons.io.FileUtils copyInputStreamToFile in Servlet org.apache.commons.io.FileUtils-更改文本编码 - org.apache.commons.io.FileUtils - change text encodig 使用org.apache.commons.io.FileUtils时Android内存泄漏 - Android memory leak when using org.apache.commons.io.FileUtils 引起原因:java.lang.ClassNotFoundException:org.apache.commons.io.FileUtils,maven pom.xml wa - Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils, maven pom.xml wa 我有导入org.apache.commons.io.FileUtils; 在我的代码中,它适用于eclipse但不适用于命令行 - I have import org.apache.commons.io.FileUtils; in my code and it works on eclipse but not in command line Java库,例如org.apache.commons.io.FileUtils,但包含实例方法而不是静态方法 - Java library like org.apache.commons.io.FileUtils but contains instance methods instead of static methods org / apache / commons / io / FileUtils-NoClassDefFoundError - org/apache/commons/io/FileUtils - NoClassDefFoundError 在 org.apache.commons.io.FileUtils.copyURLToFile 上设置超时? - Set timeout on org.apache.commons.io.FileUtils.copyURLToFile? org.apache.commons.io.FileUtils.readFileToString 和文件路径中的空白 - org.apache.commons.io.FileUtils.readFileToString and blanks in filepath 缺少方法 org.apache.commons.io.FileUtils.forceMkdirParent? - missing methode org.apache.commons.io.FileUtils.forceMkdirParent?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM