Example usage for org.apache.commons.io FilenameUtils normalize

List of usage examples for org.apache.commons.io FilenameUtils normalize

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils normalize.

Prototype

public static String normalize(String filename) 

Source Link

Document

Normalizes a path, removing double and single dot path steps.

Usage

From source file:edu.cuhk.hccl.SequenceFileWriter.java

public static void main(String[] args) throws IOException {
    // Check parameters
    if (args.length < 3) {
        System.out.print("Please specify three parameters!");
        System.exit(-1);/*from  w  w  w  . j a  v a 2s.c o m*/
    }

    File filesDir = new File(args[0]);
    String targetDir = args[1];
    final int NUM_SPLITS = Integer.parseInt(args[2]);

    // Remove old target directory first
    FileUtils.deleteQuietly(new File(targetDir));

    File[] dataFiles = filesDir.listFiles();

    int total = dataFiles.length;
    int range = (int) Math.round(total / NUM_SPLITS + 0.5);
    System.out.printf("[INFO] The number of total files is %d \n.", total);

    for (int i = 1; i <= NUM_SPLITS; i++) {
        int start = (i - 1) * range;
        int end = Math.min(start + range, total);
        File[] subFiles = Arrays.copyOfRange(dataFiles, start, end);
        createSeqFile(subFiles, FilenameUtils.normalize(targetDir + "/" + i + ".seq"));
    }

    System.out.println("[INFO] All files have been successfully processed!");
}

From source file:com.mosso.client.cloudfiles.sample.FilesCopy.java

public static void main(String args[]) throws NoSuchAlgorithmException, FilesException {
    //Build the command line options
    Options options = addCommandLineOptions();

    if (args.length <= 0)
        printHelp(options);/*w  ww.j a  v a  2  s  . c  o  m*/

    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help"))
            printHelp(options);

        if (line.hasOption("file") && line.hasOption("folder")) {
            System.err.println("Can not use both -file and -folder on the command line at the same time.");
            System.exit(-1);
        } //if (line.hasOption("file") && line.hasOption("folder"))

        if (line.hasOption("download")) {
            if (line.hasOption("folder")) {
                String localFolder = FilenameUtils.normalize(line.getOptionValue("folder"));
                String containerName = null;
                if (StringUtils.isNotBlank(localFolder)) {
                    File localFolderObj = new File(localFolder);
                    if (localFolderObj.exists() && localFolderObj.isDirectory()) {
                        if (line.hasOption("container")) {
                            containerName = line.getOptionValue("container");
                            if (!StringUtils.isNotBlank(containerName)) {
                                System.err.println(
                                        "You must provide a valid value for the  Container to upload to !");
                                System.exit(-1);
                            } //if (!StringUtils.isNotBlank(ontainerName))                            
                        } else {
                            System.err.println(
                                    "You must provide the -container for a copy operation to work as expected.");
                            System.exit(-1);
                        }

                        System.out.println("Downloading all objects from: " + containerName
                                + " to local folder: " + localFolder);

                        getContainerObjects(localFolderObj, containerName);

                    } else {
                        if (!localFolderObj.exists()) {
                            System.err.println("The local folder: " + localFolder
                                    + " does not exist.  Create it first and then run this command.");
                        }

                        if (!localFolderObj.isDirectory()) {
                            System.err.println(
                                    "The local folder name supplied : " + localFolder + " is not a folder !");
                        }

                        System.exit(-1);
                    }
                }
            }
            System.exit(0);
        } //if (line.hasOption("download"))

        if (line.hasOption("folder")) {
            String containerName = null;
            String folderPath = null;

            if (line.hasOption("container")) {
                containerName = line.getOptionValue("container");
                if (!StringUtils.isNotBlank(containerName)) {
                    System.err.println("You must provide a valid value for the  Container to upload to !");
                    System.exit(-1);
                } //if (!StringUtils.isNotBlank(containerName))

            } else {
                System.err.println("You must provide the -container for a copy operation to work as expected.");
                System.exit(-1);
            }

            folderPath = line.getOptionValue("folder");
            if (StringUtils.isNotBlank(folderPath)) {
                File folder = new File(FilenameUtils.normalize(folderPath));
                if (folder.isDirectory()) {
                    if (line.hasOption("z")) {
                        System.out.println("Zipping: " + folderPath);
                        System.out.println("Nested folders are ignored !");

                        File zipedFolder = zipFolder(folder);
                        String mimeType = FilesConstants.getMimetype(ZIPEXTENSION);
                        copyToCreateContainerIfNeeded(zipedFolder, mimeType, containerName);
                    } else {
                        File[] files = folder.listFiles();
                        for (File f : files) {
                            String mimeType = FilesConstants
                                    .getMimetype(FilenameUtils.getExtension(f.getName()));
                            System.out.println("Uploading :" + f.getName() + " to " + folder.getName());
                            copyToCreateContainerIfNeeded(f, mimeType, containerName);
                            System.out.println(
                                    "Upload :" + f.getName() + " to " + folder.getName() + " completed.");
                        }
                    }
                } else {
                    System.err.println("You must provide a valid folder value for the -folder option !");
                    System.err.println("The value provided is: " + FilenameUtils.normalize(folderPath));
                    System.exit(-1);
                }

            }
        } //if (line.hasOption("folder"))

        if (line.hasOption("file")) {
            String containerName = null;
            String fileNamePath = null;

            if (line.hasOption("container")) {
                containerName = line.getOptionValue("container");
                if (!StringUtils.isNotBlank(containerName) || containerName.indexOf('/') != -1) {
                    System.err.println("You must provide a valid value for the  Container to upload to !");
                    System.exit(-1);
                } //if (!StringUtils.isNotBlank(containerName))
            } else {
                System.err.println("You must provide the -container for a copy operation to work as expected.");
                System.exit(-1);
            }

            fileNamePath = line.getOptionValue("file");
            if (StringUtils.isNotBlank(fileNamePath)) {
                String fileName = FilenameUtils.normalize(fileNamePath);
                String fileExt = FilenameUtils.getExtension(fileNamePath);
                String mimeType = FilesConstants.getMimetype(fileExt);
                File file = new File(fileName);

                if (line.hasOption("z")) {
                    logger.info("Zipping " + fileName);
                    if (!file.isDirectory()) {
                        File zippedFile = zipFile(file);
                        mimeType = FilesConstants.getMimetype(ZIPEXTENSION);
                        copyTo(zippedFile, mimeType, containerName);
                        zippedFile.delete();
                    }

                } //if (line.hasOption("z"))
                else {

                    logger.info("Uploading " + fileName + ".");
                    if (!file.isDirectory())
                        copyTo(file, mimeType, containerName);
                    else {
                        System.err.println(
                                "The path you provided is a folder.  For uploading folders use the -folder option.");
                        System.exit(-1);
                    }
                }
            } //if (StringUtils.isNotBlank(file))
            else {
                System.err.println("You must provide a valid value for the file to upload !");
                System.exit(-1);
            }
        } //if (line.hasOption("file"))
    } //end try        
    catch (ParseException err) {
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
        err.printStackTrace(System.err);
    } //catch( ParseException err )
    catch (FilesAuthorizationException err) {
        logger.fatal("FilesAuthorizationException : Failed to login to your  account !" + err);
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
    } //catch (FilesAuthorizationException err)

    catch (IOException err) {
        logger.fatal("IOException : " + err);
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
    } //catch ( IOException err)
}

From source file:com.rackspacecloud.client.cloudfiles.sample.FilesCopy.java

public static void main(String args[]) throws NoSuchAlgorithmException, FilesException {
    //Build the command line options
    Options options = addCommandLineOptions();

    if (args.length <= 0)
        printHelp(options);/*ww  w  .  j a v  a 2  s.c  o m*/

    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help"))
            printHelp(options);

        if (line.hasOption("file") && line.hasOption("folder")) {
            System.err.println("Can not use both -file and -folder on the command line at the same time.");
            System.exit(-1);
        } //if (line.hasOption("file") && line.hasOption("folder"))

        if (line.hasOption("download")) {
            if (line.hasOption("folder")) {
                String localFolder = FilenameUtils.normalize(line.getOptionValue("folder"));
                String containerName = null;
                if (StringUtils.isNotBlank(localFolder)) {
                    File localFolderObj = new File(localFolder);
                    if (localFolderObj.exists() && localFolderObj.isDirectory()) {
                        if (line.hasOption("container")) {
                            containerName = line.getOptionValue("container");
                            if (!StringUtils.isNotBlank(containerName)) {
                                System.err.println(
                                        "You must provide a valid value for the  Container to upload to !");
                                System.exit(-1);
                            } //if (!StringUtils.isNotBlank(ontainerName))                            
                        } else {
                            System.err.println(
                                    "You must provide the -container for a copy operation to work as expected.");
                            System.exit(-1);
                        }

                        System.out.println("Downloading all objects from: " + containerName
                                + " to local folder: " + localFolder);

                        getContainerObjects(localFolderObj, containerName);

                    } else {
                        if (!localFolderObj.exists()) {
                            System.err.println("The local folder: " + localFolder
                                    + " does not exist.  Create it first and then run this command.");
                        }

                        if (!localFolderObj.isDirectory()) {
                            System.err.println(
                                    "The local folder name supplied : " + localFolder + " is not a folder !");
                        }

                        System.exit(-1);
                    }
                }
            }
            System.exit(0);
        } //if (line.hasOption("download"))

        if (line.hasOption("folder")) {
            String containerName = null;
            String folderPath = null;

            if (line.hasOption("container")) {
                containerName = line.getOptionValue("container");
                if (!StringUtils.isNotBlank(containerName)) {
                    System.err.println("You must provide a valid value for the  Container to upload to !");
                    System.exit(-1);
                } //if (!StringUtils.isNotBlank(containerName))

            } else {
                System.err.println("You must provide the -container for a copy operation to work as expected.");
                System.exit(-1);
            }

            folderPath = line.getOptionValue("folder");
            if (StringUtils.isNotBlank(folderPath)) {
                File folder = new File(FilenameUtils.normalize(folderPath));
                if (folder.isDirectory()) {
                    if (line.hasOption("z")) {
                        System.out.println("Zipping: " + folderPath);
                        System.out.println("Nested folders are ignored !");

                        File zipedFolder = zipFolder(folder);
                        String mimeType = FilesConstants.getMimetype(ZIPEXTENSION);
                        copyToCreateContainerIfNeeded(zipedFolder, mimeType, containerName);
                    } else {
                        File[] files = folder.listFiles();
                        for (File f : files) {
                            String mimeType = FilesConstants
                                    .getMimetype(FilenameUtils.getExtension(f.getName()));
                            System.out.println("Uploading :" + f.getName() + " to " + folder.getName());
                            copyToCreateContainerIfNeeded(f, mimeType, containerName);
                            System.out.println(
                                    "Upload :" + f.getName() + " to " + folder.getName() + " completed.");
                        }
                    }
                } else {
                    System.err.println("You must provide a valid folder value for the -folder option !");
                    System.err.println("The value provided is: " + FilenameUtils.normalize(folderPath));
                    System.exit(-1);
                }

            }
        } //if (line.hasOption("folder"))

        if (line.hasOption("file")) {
            String containerName = null;
            String fileNamePath = null;

            if (line.hasOption("container")) {
                containerName = line.getOptionValue("container");
                if (!StringUtils.isNotBlank(containerName) || containerName.indexOf('/') != -1) {
                    System.err.println("You must provide a valid value for the  Container to upload to !");
                    System.exit(-1);
                } //if (!StringUtils.isNotBlank(containerName))
            } else {
                System.err.println("You must provide the -container for a copy operation to work as expected.");
                System.exit(-1);
            }

            fileNamePath = line.getOptionValue("file");
            if (StringUtils.isNotBlank(fileNamePath)) {
                String fileName = FilenameUtils.normalize(fileNamePath);
                String fileExt = FilenameUtils.getExtension(fileNamePath);
                String mimeType = FilesConstants.getMimetype(fileExt);
                File file = new File(fileName);

                if (line.hasOption("z")) {
                    logger.info("Zipping " + fileName);
                    if (!file.isDirectory()) {
                        File zippedFile = zipFile(file);
                        mimeType = FilesConstants.getMimetype(ZIPEXTENSION);
                        copyTo(zippedFile, mimeType, containerName);
                        zippedFile.delete();
                    }

                } //if (line.hasOption("z"))
                else {

                    logger.info("Uploading " + fileName + ".");
                    if (!file.isDirectory())
                        copyTo(file, mimeType, containerName);
                    else {
                        System.err.println(
                                "The path you provided is a folder.  For uploading folders use the -folder option.");
                        System.exit(-1);
                    }
                }
            } //if (StringUtils.isNotBlank(file))
            else {
                System.err.println("You must provide a valid value for the file to upload !");
                System.exit(-1);
            }
        } //if (line.hasOption("file"))
    } //end try        
    catch (ParseException err) {
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
        err.printStackTrace(System.err);
    } //catch( ParseException err )
    catch (FilesAuthorizationException err) {
        logger.fatal("FilesAuthorizationException : Failed to login to your  account !" + err);
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
    } //catch (FilesAuthorizationException err)

    catch (Exception err) {
        logger.fatal("IOException : " + err);
        System.err.println("Please see the logs for more details. Error Message: " + err.getMessage());
    } //catch ( IOException err)
}

From source file:io.cloudslang.lang.tools.build.SlangBuildMain.java

public static void main(String[] args) {
    loadUserProperties();/*  w  w w  . j a v  a 2s.c o  m*/
    configureLog4j();

    ApplicationArgs appArgs = new ApplicationArgs();
    parseArgs(args, appArgs);
    String projectPath = parseProjectPathArg(appArgs);
    final String contentPath = defaultIfEmpty(appArgs.getContentRoot(), projectPath + CONTENT_DIR);
    final String testsPath = defaultIfEmpty(appArgs.getTestRoot(), projectPath + TEST_DIR);
    List<String> testSuites = parseTestSuites(appArgs);
    boolean shouldPrintCoverageData = appArgs.shouldOutputCoverage();
    boolean runTestsInParallel = appArgs.isParallel();
    int threadCount = parseThreadCountArg(appArgs, runTestsInParallel);
    String testCaseTimeout = parseTestTimeout(appArgs);
    setProperty(TEST_CASE_TIMEOUT_IN_MINUTES_KEY, valueOf(testCaseTimeout));
    final boolean shouldValidateDescription = appArgs.shouldValidateDescription();
    final boolean shouldValidateCheckstyle = appArgs.shouldValidateCheckstyle();
    String runConfigPath = FilenameUtils.normalize(appArgs.getRunConfigPath());

    BuildMode buildMode = null;
    Set<String> changedFiles = null;
    try {
        String smartModePath = appArgs.getChangesOnlyConfigPath();
        if (StringUtils.isEmpty(smartModePath)) {
            buildMode = BuildMode.BASIC;
            changedFiles = new HashSet<>();
            printBuildModeInfo(buildMode);
        } else {
            buildMode = BuildMode.CHANGED;
            changedFiles = readChangedFilesFromSource(smartModePath);
            printBuildModeInfo(buildMode);
        }
    } catch (Exception ex) {
        log.error("Exception: " + ex.getMessage());
        System.exit(1);
    }

    // Override with the values from the file if configured
    List<String> testSuitesParallel = new ArrayList<>();
    List<String> testSuitesSequential = new ArrayList<>();
    BulkRunMode bulkRunMode = runTestsInParallel ? ALL_PARALLEL : ALL_SEQUENTIAL;

    TestCaseRunMode unspecifiedTestSuiteRunMode = runTestsInParallel ? TestCaseRunMode.PARALLEL
            : TestCaseRunMode.SEQUENTIAL;
    if (get(runConfigPath).isAbsolute() && isRegularFile(get(runConfigPath), NOFOLLOW_LINKS)
            && equalsIgnoreCase(PROPERTIES_FILE_EXTENSION, FilenameUtils.getExtension(runConfigPath))) {
        Properties runConfigurationProperties = ArgumentProcessorUtils.getPropertiesFromFile(runConfigPath);
        shouldPrintCoverageData = getBooleanFromPropertiesWithDefault(TEST_COVERAGE, shouldPrintCoverageData,
                runConfigurationProperties);
        threadCount = getIntFromPropertiesWithDefaultAndRange(TEST_PARALLEL_THREAD_COUNT,
                Runtime.getRuntime().availableProcessors(), runConfigurationProperties, 1,
                MAX_THREADS_TEST_RUNNER + 1);
        testSuites = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_TO_RUN);
        testSuitesParallel = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_PARALLEL);
        testSuitesSequential = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_SEQUENTIAL);
        addErrorIfSameTestSuiteIsInBothParallelOrSequential(testSuitesParallel, testSuitesSequential);
        unspecifiedTestSuiteRunMode = getEnumInstanceFromPropertiesWithDefault(TEST_SUITES_RUN_UNSPECIFIED,
                unspecifiedTestSuiteRunMode, runConfigurationProperties);
        addWarningsForMisconfiguredTestSuites(unspecifiedTestSuiteRunMode, testSuites, testSuitesSequential,
                testSuitesParallel);
        bulkRunMode = POSSIBLY_MIXED;
    } else { // Warn when file is misconfigured, relative path, file does not exist or is not a properties file
        log.info(format(DID_NOT_DETECT_RUN_CONFIGURATION_PROPERTIES_FILE, runConfigPath));
    }

    String testCaseReportLocation = getProperty(TEST_CASE_REPORT_LOCATION);
    if (StringUtils.isBlank(testCaseReportLocation)) {
        log.info("Test case report location property [" + TEST_CASE_REPORT_LOCATION
                + "] is not defined. Report will be skipped.");
    }

    // Setting thread count for visibility in ParallelTestCaseExecutorService
    setProperty(SLANG_TEST_RUNNER_THREAD_COUNT, valueOf(threadCount));

    log.info(NEW_LINE + "------------------------------------------------------------");
    log.info("Building project: " + projectPath);
    log.info("Content root is at: " + contentPath);
    log.info("Test root is at: " + testsPath);
    log.info("Active test suites are: " + getListForPrint(testSuites));
    log.info("Parallel run mode is configured for test suites: " + getListForPrint(testSuitesParallel));
    log.info("Sequential run mode is configured for test suites: " + getListForPrint(testSuitesSequential));
    log.info("Default run mode '" + unspecifiedTestSuiteRunMode.name().toLowerCase()
            + "' is configured for test suites: " + getListForPrint(
                    getDefaultRunModeTestSuites(testSuites, testSuitesParallel, testSuitesSequential)));

    log.info("Bulk run mode for tests: " + getBulkModeForPrint(bulkRunMode));

    log.info("Print coverage data: " + valueOf(shouldPrintCoverageData));
    log.info("Validate description: " + valueOf(shouldValidateDescription));
    log.info("Validate checkstyle: " + valueOf(shouldValidateCheckstyle));
    log.info("Thread count: " + threadCount);
    log.info("Test case timeout in minutes: "
            + (isEmpty(testCaseTimeout) ? valueOf(MAX_TIME_PER_TESTCASE_IN_MINUTES) : testCaseTimeout));

    log.info(NEW_LINE + "Loading...");

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/testRunnerContext.xml");
    context.registerShutdownHook();
    SlangBuilder slangBuilder = context.getBean(SlangBuilder.class);
    LoggingService loggingService = context.getBean(LoggingServiceImpl.class);
    Slang slang = context.getBean(Slang.class);

    try {

        updateTestSuiteMappings(context.getBean(TestRunInfoService.class), testSuitesParallel,
                testSuitesSequential, testSuites, unspecifiedTestSuiteRunMode);

        registerEventHandlers(slang);

        List<RuntimeException> exceptions = new ArrayList<>();

        SlangBuildResults buildResults = slangBuilder.buildSlangContent(projectPath, contentPath, testsPath,
                testSuites, shouldValidateDescription, shouldValidateCheckstyle, bulkRunMode, buildMode,
                changedFiles);
        exceptions.addAll(buildResults.getCompilationExceptions());
        if (exceptions.size() > 0) {
            logErrors(exceptions, projectPath, loggingService);
        }
        IRunTestResults runTestsResults = buildResults.getRunTestsResults();
        Map<String, TestRun> skippedTests = runTestsResults.getSkippedTests();

        if (isNotEmpty(skippedTests)) {
            printSkippedTestsSummary(skippedTests, loggingService);
        }
        printPassedTests(runTestsResults, loggingService);
        if (shouldPrintCoverageData) {
            printTestCoverageData(runTestsResults, loggingService);
        }

        if (isNotEmpty(runTestsResults.getFailedTests())) {
            printBuildFailureSummary(projectPath, runTestsResults, loggingService);
        } else {
            printBuildSuccessSummary(contentPath, buildResults, runTestsResults, loggingService);
        }
        loggingService.waitForAllLogTasksToFinish();

        generateTestCaseReport(context.getBean(SlangTestCaseRunReportGeneratorService.class), runTestsResults,
                testCaseReportLocation);
        System.exit(isNotEmpty(runTestsResults.getFailedTests()) ? 1 : 0);

    } catch (Throwable e) {
        logErrorsPrefix(loggingService);
        loggingService.logEvent(Level.ERROR, "Exception: " + e.getMessage());
        logErrorsSuffix(projectPath, loggingService);
        loggingService.waitForAllLogTasksToFinish();
        System.exit(1);
    }
}

From source file:ch.unibas.fittingwizard.infrastructure.base.ScriptUtilities.java

public static void deleteFileIfExists(File resultsFile) {
    if (resultsFile.exists()) {
        logger.info("Deleting existing file. " + FilenameUtils.normalize(resultsFile.getAbsolutePath()));
        if (resultsFile.delete()) {
            logger.info("File deleted.");
        } else {//from   w  ww  .  j a v  a2s. c  o m
            logger.error("Could not delete file.");
        }
    }
}

From source file:com.thoughtworks.go.util.FilenameUtil.java

public static boolean isNormalizedDirectoryPathInsideNormalizedParentDirectory(String parent,
        String subdirectory) {/*from   w  w w.  ja  v a  2  s  .  c o  m*/
    final String normalizedParentPath = FilenameUtils.normalize(parent + File.separator);
    final String normalizedSubDirPath = FilenameUtils.normalize(subdirectory + File.separator);
    return StringUtils.isNotBlank(normalizedParentPath) && StringUtils.isNotBlank(normalizedSubDirPath)
            && normalizedSubDirPath.startsWith(normalizedParentPath);
}

From source file:com.robin.testcase.ApkResigner.java

static synchronized void resignAUT(final File autFile) {
    String signedAutFullPath = getReSignedAUT(autFile).getAbsolutePath();
    if (!reSignedApkExists(signedAutFullPath)) {
        String apkAbsolutePath = autFile.getAbsolutePath();
        String normalizedPath = FilenameUtils.normalize(apkAbsolutePath);
        Reporter.log("Resign '" + normalizedPath + "', to create '" + signedAutFullPath + "'.", true);
        // Set environment for Resigner class.
        ResignerLogic.checkEnvironment();
        try {//from   ww w. ja v a  2s  .c o  m
            ResignerLogic.resign(apkAbsolutePath, signedAutFullPath);
        } catch (Exception e) {
            Assert.fail("FAILED TO RESIGN " + normalizedPath);
        }
    } else {
        Reporter.log("Resigned '" + signedAutFullPath + "' found.", true);
    }
}

From source file:avantssar.aslanpp.testing.HTMLHelper.java

public static String removePrefix(File root, File f) {
    String fNorm = FilenameUtils.normalize(f.getAbsolutePath());
    String relativePath = fNorm;/*from   w ww  .  ja  v a 2 s. com*/
    if (root.isDirectory()) {
        String rootNorm = FilenameUtils.normalizeNoEndSeparator(root.getAbsolutePath()) + File.separator;
        if (relativePath.startsWith(rootNorm)) {
            relativePath = relativePath.substring(rootNorm.length());
        }
    }
    return relativePath;
}

From source file:ch.unibas.fittingwizard.infrastructure.base.ScriptUtilities.java

public static void verifyFileExistence(File file) {
    if (!file.exists()) {
        throw new ScriptExecutionException(
                "Script did not create expected " + FilenameUtils.normalize(file.getAbsolutePath()) + " file.");
    }/*w  w  w . j a  v  a  2 s.  com*/
}

From source file:com.thoughtworks.go.util.FilenameUtil.java

public static boolean isNormalizedPathOutsideWorkingDir(String path) {
    final String normalize = FilenameUtils.normalize(path);
    final String prefix = FilenameUtils.getPrefix(normalize);
    return (normalize != null && StringUtils.isBlank(prefix));
}