Class Filenames


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String toSimpleFileName​(java.lang.String fileName)
      Take an arbitrary file path (full, relative, or a simple name) and return a guaranteed simple name without any directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toSimpleFileName

        public static java.lang.String toSimpleFileName​(java.lang.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