Example usage for org.springframework.util StringUtils getFilenameExtension

List of usage examples for org.springframework.util StringUtils getFilenameExtension

Introduction

In this page you can find the example usage for org.springframework.util StringUtils getFilenameExtension.

Prototype

@Nullable
public static String getFilenameExtension(@Nullable String path) 

Source Link

Document

Extract the filename extension from the given Java resource path, e.g.

Usage

From source file:org.springframework.xd.integration.test.HdfsTest.java

private String getTestFilePath(String directory, FileStatus status) {
    String fileName = status.getPath().getName();
    if (StringUtils.getFilenameExtension(fileName).equals("tmp")) {
        fileName = FilenameUtils.removeExtension(fileName);
    }/*  www.  j a va  2  s  .co m*/
    return directory + "/" + fileName;
}

From source file:uk.ac.ebi.metabolights.controller.FileDispatcherController.java

public static void streamFile(File file, HttpServletResponse response) {

    // get the extension
    String extension = StringUtils.getFilenameExtension(file.getName());

    // let the browser know the type of file
    String contenType = "application/" + extension;

    streamFile(file, response, contenType);

}