Java Is Same File isSame(File file1, File file2)

Here you can find the source of isSame(File file1, File file2)

Description

is Same

License

Apache License

Declaration

public static boolean isSame(File file1, File file2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.IOException;

public class Main {
    public static boolean isSame(File file1, File file2) {
        return canonicalFile(file1).equals(canonicalFile(file2));
    }// w  w  w.j av  a2s  .  c o m

    public static boolean equals(File fileA, File fileB) {
        return canonicalFile(fileA).equals(canonicalFile(fileB));
    }

    /**
     * A 'checked exception free' version of {@link File#getCanonicalFile()}.
     */
    public static File canonicalFile(File file) {
        try {
            return file.getCanonicalFile();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. isSame(File file1, File file2)
  2. isSame(File fileA, File fileB)