集册 Java实例教程 比较两条路径

比较两条路径

欢马劈雪     最近更新时间:2020-01-02 10:19:05

550
比较两条路径
import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;//from nowjava


public class Main {


    public static void main(String[] args) {


        Path path01 = Paths.get("/folder1/folder2/folder3/test.txt");

        Path path02 = Paths.get("C:/folder1/folder2/folder3/test.txt");


        //compare using Path.equals

        if (path01.equals(path02)) {

            System.out.println(
展开阅读全文