日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java两个文件夹比较路径_比较Java中两个文件的路径

發(fā)布時間:2023/12/1 java 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java两个文件夹比较路径_比较Java中两个文件的路径 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

java兩個文件夾比較路徑

Given the paths of the two files and we have two compare the paths of the files in Java.

給定兩個文件的路徑,我們有兩個比較Java中文件的路徑。

Comparing paths of two files

比較兩個文件的路徑

To compare the paths of two files, we can use compareTo() method, it is called with a file object and second file path passes as an argument and method returns 0 if both file paths are the same.

為了比較兩個文件的路徑 ,我們可以使用compareTo()方法 ,該方法與文件對象一起調(diào)用,第二個文件路徑作為參數(shù)傳遞,并且如果兩個文件路徑相同,則方法返回0。

Syntax:

句法:

//file object creationFile F1 = new File("d://courses//intro.docx");File F2 = new File("d://courses//intro.docx");//comparing file paths of F1 and F2F1.compareTo(F2);Output:0

Java代碼比較兩個文件的路徑 (Java code to compare the paths of two files)

//Java code to compare the paths of two files import java.io.*;public class Main {public static void main(String[] args) {//file object creationFile F1 = new File("d://courses//intro.docx");File F2 = new File("d://courses//intro.docx");File F3 = new File("d://courses//basic.docx");//comparing file paths using compareTo() method//comparing file paths of F1 and F2if (F1.compareTo(F2) == 0) {System.out.println("paths of F1 and F2 are same...");} else {System.out.println("paths of F1 and F2 are not same...");}//comparing file paths of F2 and F3if (F2.compareTo(F3) == 0) {System.out.println("paths of F2 and F3 are same...");} else {System.out.println("paths of F2 and F3 are not same...");}//comparing file paths of F3 and F1if (F3.compareTo(F1) == 0) {System.out.println("paths of F3 and F1 are same...");} else {System.out.println("paths of F3 and F1 are not same...");}} }

Output

輸出量

paths of F1 and F2 are same... paths of F2 and F3 are not same... paths of F3 and F1 are not same...

翻譯自: https://www.includehelp.com/java-programs/comparing-the-paths-of-the-two-files-in-java.aspx

java兩個文件夾比較路徑

總結(jié)

以上是生活随笔為你收集整理的java两个文件夹比较路径_比较Java中两个文件的路径的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。