Example usage for org.apache.commons.io IOCase checkEndsWith

List of usage examples for org.apache.commons.io IOCase checkEndsWith

Introduction

In this page you can find the example usage for org.apache.commons.io IOCase checkEndsWith.

Prototype

public boolean checkEndsWith(String str, String end) 

Source Link

Document

Checks if one string ends with another using the case-sensitivity rule.

Usage

From source file:org.eclipse.smila.utils.scriptexecution.WindowsScriptExecutor.java

/**
 * {@inheritDoc}/*from  ww  w. jav a 2  s. c o  m*/
 */
public int execute(final File file) throws IOException, InterruptedException {

    _log.debug("Executing " + file.getAbsolutePath());

    final String fileName = file.getName();

    final IOCase ioCase = IOCase.SYSTEM;

    if (!ioCase.checkEndsWith(fileName, ".cmd") && !ioCase.checkEndsWith(fileName, ".bat")) {

        _log.debug("It doesn't end with .cmd or .bat");

        final File tempFile = getTempCmdFile(file.getParentFile());

        try {

            _log.debug("Copy " + file.getAbsolutePath() + " to " + tempFile);
            FileUtils.copyFile(file, tempFile);

            return doExecute(tempFile);

        } finally {

            tempFile.delete();
        }
    } else {

        return doExecute(file);
    }
}