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

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

Introduction

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

Prototype

public static String getExtension(String filename) 

Source Link

Document

Gets the extension of a filename.

Usage

From source file:languageTools.utils.Extension.java

/**
 * Determines the {@link Extension} of a certain file.
 *
 * @param filename/*from  w w  w. j  ava2s.c  om*/
 *            The name or path to a file to get the extension of
 * @return The {@link Extension} of the given file, or <code>null</code> if
 *         the file has no known extension.
 */
public static Extension getFileExtension(String filename) {
    try {
        return Extension.valueOf(FilenameUtils.getExtension(filename).toUpperCase());
    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:io.proleap.cobol.runner.impl.CobolParseTestRunnerImpl.java

protected static boolean isCobolFile(final File inputFile) {
    final String extension = FilenameUtils.getExtension(inputFile.getName()).toLowerCase();
    return inputFile.isFile() && Arrays.asList(cobolFileExtensions).contains(extension);
}

From source file:com.siberhus.web.ckeditor.utils.FileUtils.java

public static boolean isFileAllowed(String filename, String type) {
    String fileExt = FilenameUtils.getExtension(filename);
    return isAllowed(fileExt, type);
}

From source file:com.teradata.tempto.internal.convention.SqlTestsFileUtils.java

public static String getExtension(Path path) {
    return FilenameUtils.getExtension(path.getFileName().toString());
}

From source file:com.github.dokandev.dokanjava.samples.memoryfs.Utils.java

public static String toShortName(String fileName) {
    String base = FilenameUtils.getBaseName(fileName);
    if (base.length() > 8)
        base = base.substring(8);//from   w ww.j  a v a  2s  .  c o  m

    String ext = FilenameUtils.getExtension(fileName);
    if (ext.length() > 3)
        ext = ext.substring(3);
    if (ext.length() > 0)
        ext = "." + ext;

    return base + ext;
}

From source file:filters.SupportedFormats.java

public static String getFormatExtension(String path) {
    return FilenameUtils.getExtension(path).toLowerCase().trim();
}

From source file:cn.org.once.cstack.model.DeploymentType.java

public static DeploymentType from(String name) {
    return EnumSet.allOf(DeploymentType.class).stream()
            .filter(t -> FilenameUtils.getExtension(name).equalsIgnoreCase(t.extension)).findFirst()
            .orElse(DeploymentType.JAR);
}

From source file:net.grinder.lang.Lang.java

/**
 * Get {@link Lang} enum by the given filename.
 *
 * @param fileName filename//from  ww w . ja  v a  2  s . com
 * @return {@link Lang} enum value
 */
public static Lang getByFileName(String fileName) {
    String extension = FilenameUtils.getExtension(fileName);
    for (Lang each : values()) {
        if (each.getHandler().getExtension().equals(extension)) {
            return each;
        }
    }
    return Unknown;
}

From source file:Api.RequestValidator.java

public void validate() throws NotSuportedFileFormatException, FileNotFoundException {
    if (!checkFileExists())
        throw new FileNotFoundException();
    if (!checkFileFormat())
        throw new NotSuportedFileFormatException(FilenameUtils.getExtension(filePath));
}

From source file:eu.planets_project.services.utils.test.FileAccess.java

private static void index(File root, Map<String, File> map) {
    String[] list = root.list();/*ww w. j  av a 2s. co m*/
    for (String name : list) {
        File f = new File(root, name);
        if (f.isDirectory() && !f.isHidden()) {
            index(f, map);
        } else if (f.isFile() && !f.isHidden()) {
            map.put(FilenameUtils.getExtension(f.getName()).toLowerCase(), f);
        }
    }
}