Java Directory Check checkDirCopy(File srcDir, File destDir)

Here you can find the source of checkDirCopy(File srcDir, File destDir)

Description

check Dir Copy

License

Open Source License

Declaration

private static void checkDirCopy(File srcDir, File destDir) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.FileNotFoundException;

import java.io.IOException;

public class Main {
    private static void checkDirCopy(File srcDir, File destDir) throws IOException {
        if (!srcDir.exists()) {
            throw new FileNotFoundException("Source '" + srcDir + "' does not exist.");
        }/*from   ww w  .  j  av a 2  s . c  o m*/
        if (!srcDir.isDirectory()) {
            throw new IOException("Source '" + srcDir + "' is not a directory.");
        }
        if (equals(srcDir, destDir)) {
            throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same.");
        }
    }

    /**
     * Checks if two files points to the same file.
     */
    public static boolean equals(String file1, String file2) {
        return equals(new File(file1), new File(file2));
    }

    /**
     * Checks if two files points to the same file.
     */
    public static boolean equals(File file1, File file2) {
        try {
            file1 = file1.getCanonicalFile();
            file2 = file2.getCanonicalFile();
        } catch (IOException ioex) {
            return false;
        }
        return file1.equals(file2);
    }
}

Related

  1. checkDir(String name)
  2. checkDir(String path)
  3. checkDir(String path)
  4. checkDir(String pDir)
  5. checkDirAndCreate(File dir)
  6. checkDirectory(File dir)
  7. checkDirectory(File directory)
  8. checkDirectory(File directory)
  9. checkDirectory(File directory)