Java 实例 - 文件路径比较
Java 教程
· 2019-02-10 23:26:22
以下实例演示了使用 File 类的 filename.compareTo (another filename) 方法来比较两个文件路径是否在同一个目录下:
Main.java 文件
import java.io.File;
public class Main {
public static void main(String[] args) {
File file1 = new File("C:/File/demo1.txt");
File file2 = new File("C:/java/demo1.txt");
if(file1.compareTo(file2) == 0) {
System.out.println("文件路径一致!");
} else {
System.out.println("文件路径不一致!");
}
}
}
以上代码运行输出结果为:
文件路径不一致!
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
Cypherpunks
Julian Assange、Jacob Appelbaum、Andy Müller-Maguhn、Jérémie Zimmermann / OR Books / 2012-11 / GBP 8.99
Cypherpunks are activists who advocate the widespread use of strong cryptography (writing in code) as a route to progressive change. Julian Assange, the editor-in-chief of and visionary behind WikiLea......一起来看看 《Cypherpunks》 这本书的介绍吧!