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:net.sf.jvifm.control.CompressCommand.java

public void execute() {

    String ext = FilenameUtils.getExtension(dstFile);

    try {/*from   w w w.  j av  a  2  s .  c  o m*/
        if (ext.equals("zip") || ext.equals("jar") || ext.equals("war") || ext.equals("ear")) {
            fileModelManager.zip(dstFile, paths);

        } else if (ext.equals("tar")) {
            fileModelManager.tar(dstFile, paths, null);
        } else if (ext.equals("tgz") || dstFile.endsWith("tar.gz")) {
            fileModelManager.tar(dstFile, paths, "gz");
        } else if (dstFile.endsWith("tar.bz2")) {
            fileModelManager.tar(dstFile, paths, "bz2");
        } else {
            Util.openMessageWindow("unknow archive format");
            return;
        }
    } catch (Exception e) {
        Util.openMessageWindow(e.getMessage());
    }
    switchToNormal();
}

From source file:com.hillert.si.HeaderEnricherHandler.java

/**
 * //from  w  w w .j  a v  a  2 s  .  c  om
 */
public String enrichFilenameHeader(final Message<File> inputMessage) {

    final File inputFile = inputMessage.getPayload();
    final String filename = inputFile.getName();
    final String fileExtension = FilenameUtils.getExtension(filename);
    final Integer priority = inputMessage.getHeaders().getPriority();

    return dateFormat.format(new Date()) + "_Prio-" + priority + "_" + filename + "." + fileExtension;

}

From source file:net.sf.jvifm.control.UnCompressCommand.java

public void execute() {
    String ext = FilenameUtils.getExtension(archiveFilePath);

    try {/*from   w ww  . jav  a 2 s.c  o  m*/
        if (ext.equals("zip") || ext.equals("jar") || ext.equals("war") || ext.equals("ear")) {

            fileModelManager.unzip(archiveFilePath, dstPath);

        } else if (ext.equals("tar") || ext.equals("tgz") || archiveFilePath.endsWith("tar.bz2")
                || archiveFilePath.endsWith("tar.gz")) {
            fileModelManager.untar(archiveFilePath, dstPath);
        } else {
            Util.openMessageWindow("unknow archive format");
            return;
        }

    } catch (Exception e) {
        Util.openMessageWindow(e.getMessage());
        e.printStackTrace();
    }
}

From source file:net.mitnet.tools.pdf.book.io.FileSuffixExclusionFilter.java

@Override
public boolean accept(File file) {

    boolean result = false;

    String fileName = file.getName();
    String fileExt = FilenameUtils.getExtension(fileName);

    if (!this.exclusionList.contains(fileExt)) {
        result = true;//from w w  w.jav a  2  s.c om
    }

    return result;
}

From source file:AIR.Common.Utilities.Path.java

public static String getExtension(String fileName) {
    return FilenameUtils.getExtension(fileName);
}

From source file:com.book.identification.FileFilter.java

public synchronized boolean accept(File file) {

    Iterator<FileType> iterator = fileTypes.iterator();
    boolean result = false;
    while (iterator.hasNext()) {
        if (file.isFile()) {
            String extension = FilenameUtils.getExtension(file.getName());
            if (StringUtils.equalsIgnoreCase(iterator.next().toString(), extension)) {
                result = true;/*  w ww .j a  v a 2s.com*/
                break;
            }
        } else {
            result = true;
            break;
        }
    }
    return result;
}

From source file:Main.StaticTools.java

public static Boolean supportedMediaFileType(String name) {
    String ext = FilenameUtils.getExtension(name.toLowerCase());
    for (String extSupported : imageFiles) {
        if (ext.equals(extSupported))
            return true;
    }/*from   w  w  w  . j  av  a 2s .  co  m*/
    for (String extSupported : videoFiles) {
        if (ext.equals(extSupported))
            return true;
    }
    return false;
}

From source file:jease.cms.web.content.editor.ScriptEditor.java

public ScriptEditor() {
    code.setHeight((100 + getDesktopHeight() / 3) + "px");
    code.setConfig("lineNumbers:true");
    id.addEventListener(Events.ON_CHANGING,
            event -> code.setSyntax(FilenameUtils.getExtension(((InputEvent) event).getValue())));
}

From source file:audiomanagershell.commands.PlayCommand.java

@Override
public void execute() throws CommandException, IOException {
    String OS = System.getProperty("os.name").toLowerCase();
    Path file;/*from  w w  w  .  j  ava  2s. c  o m*/
    if (OS.equals("windows"))
        file = Paths.get(this.pathRef.toString() + "\\" + this.arg);
    else
        file = Paths.get(this.pathRef.toString() + "/" + this.arg);
    String fileName = file.getFileName().toString();
    List<String> acceptedExtensions = Arrays.asList("wav", "mp3", "flac", "mp4");
    //Get the extension of the file
    String extension = FilenameUtils.getExtension(fileName);
    if (Files.isRegularFile(file) && Files.isReadable(file)) {
        if (acceptedExtensions.contains(extension)) {
            Desktop desktop = Desktop.getDesktop();
            desktop.open(file.toFile());
            System.out.printf("The file %s will open shortly...\n", fileName);
        } else {
            throw new NotAudioFileException(fileName);
        }
    } else {
        throw new CommandException(file.toString() + " not a file or can't read");
    }
}

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

private static String getReSignedAutName(final File autFile) {
    String autName = autFile.getName();
    String autFileCanonical = null;
    try {/*w  w  w.j a v  a 2 s .c  o  m*/
        autFileCanonical = autFile.getCanonicalPath();
    } catch (IOException e) {
        e.printStackTrace();
    }

    String newAutNameFolderPart = getUnderLinedPath(autFileCanonical);
    String newAutNameFileNamePart = FilenameUtils.getBaseName(autName);
    String newAutName = newAutNameFolderPart + "_" + newAutNameFileNamePart;
    String newAutNameWithExtension = newAutName + "_" + getAutVersion(autFile) + "."
            + FilenameUtils.getExtension(autName);
    return newAutNameWithExtension;
}