Package edu.monash.merc.exception

Examples of edu.monash.merc.exception.DCFileException


    private static Logger logger = Logger.getLogger(DCFileUtils.class.getName());

    public static boolean checkWritePermission(String pathName) {
        if (pathName == null) {
            throw new DCFileException("directory name must not be null");
        }
        try {
            File dir = new File(pathName);
            return dir.canWrite();
        } catch (Exception e) {
View Full Code Here


        }
    }

    public static void deleteDirectory(String dirName) {
        if (dirName == null) {
            throw new DCFileException("directory name must not be null");
        }

        try {
            FileUtils.deleteDirectory(new File(dirName));
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

        }
    }

    public static void moveDirectory(String olderDirName, String newDirName) {
        if (olderDirName == null) {
            throw new DCFileException("old directory name must not be null");
        }
        if (newDirName == null) {
            throw new DCFileException("new directory name must not be null");
        }
        try {
            FileUtils.moveDirectory(new File(olderDirName), new File(newDirName));
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

        }
    }

    public static void createDirectory(String dirName) {
        if (dirName == null) {
            throw new DCFileException("directory name must not be null");
        }
        try {
            FileUtils.forceMkdir(new File(dirName));
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

    }

    public static void copyFile(String srcFileName, String destFileName, boolean preserveFileDate) {

        if (srcFileName == null) {
            throw new DCFileException("Source must not be null");
        }
        if (destFileName == null) {
            throw new DCFileException("Destination must not be null");
        }
        File srcFile = new File(srcFileName);
        File destFile = new File(destFileName);

        if (!srcFile.exists()) {
            throw new DCFileException("Source '" + srcFile + "' does not exist");
        }
        if (srcFile.isDirectory()) {
            throw new DCFileException("Source '" + srcFile + "' is a directory");
        }

        if (destFile.isDirectory()) {
            throw new DCFileException("Destination '" + destFile + "' is a directory");
        }
        try {
            FileUtils.copyFile(srcFile, destFile, preserveFileDate);
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

    public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) {
        try {
            FileUtils.copyFile(srcFile, destFile, preserveFileDate);
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

            File file = new File(fileName);
            if (file.exists()) {
                FileUtils.forceDelete(new File(fileName));
            }
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

    public static byte[] readFileToByteArray(String fileName) {
        try {
            return FileUtils.readFileToByteArray(new File(fileName));
        } catch (Exception e) {
            throw new DCFileException(e);
        }
    }
View Full Code Here

        }
    }

    public static InputStream readFileToInputStream(String fileName) {
        if (fileName == null) {
            throw new DCFileException("file name must not be null");
        }
        InputStream in = null;
        try {
            in = new BufferedInputStream(new FileInputStream(fileName));
        } catch (Exception e) {
            throw new DCFileException(e);
        }
        return in;
    }
View Full Code Here

    }

    public static List<String> discoverFileNames(String stagePath, FilenameFilter filter) {

        if (stagePath == null) {
            throw new DCFileException("directory must not be null");
        }
        File scannedDir = new File(stagePath);

        if (scannedDir.exists() && scannedDir.isFile()) {
            throw new DCFileException("Destination '" + stagePath + "' exists but is a file");
        }

        if (filter == null) {
            filter = new ScanFileFilter();
        }
View Full Code Here

TOP

Related Classes of edu.monash.merc.exception.DCFileException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.