Class Filenames


  • public final class Filenames
    extends Object
    This type offers utilities to safely deal with filenames.
    • Method Detail

      • toSimpleFileName

        public static String toSimpleFileName​(String fileName)
        Take an arbitrary file path (full, relative, or a simple name) and return a guaranteed simple name without any directory. For instance:
        the inputs and outputs of the API showing all the directory elements of the paths taken out
        Input Output
        ../whatever/foo.txt foo.txt
        C:\foo.txt foo.txt
        foo.txt foo.txt
        Parameters:
        fileName - the file name to normalize
        Returns:
        a directoryless version of a file name
        See Also:
        Spring Multipart warning, RFC 7578, Section 4.2, Unrestricted File Upload