Class FilenameUtils

java.lang.Object
org.ametys.core.util.FilenameUtils

public final class FilenameUtils extends Object
Utility class for encoding file names and paths.
These methods are used to provide safe names to be stored on disk.
The encode* methods %-encode all reserved chars, plus the '%' char itself.
The filter* methods replace reserved chars with the '_' char.

Reserved chars are
\ / ? : * | " < >
  • Field Details

  • Method Details

    • encodePath

      public static String encodePath(String path)
      %-encode a file path to be stored on disk.
      Parameters:
      path - the file path to encode
      Returns:
      the encoded file path.
    • encodeName

      public static String encodeName(String name)
      %-encode a file name to be stored on disk.
      Parameters:
      name - the file name to encode
      Returns:
      the encoded file name.
    • filterPath

      public static String filterPath(String path)
      Replace reserved characters from a file path with a _.
      Parameters:
      path - the file path to transform
      Returns:
      the filtered file path
    • filterName

      public static String filterName(String name)
      Replace reserved characters from a file name with a _.
      Parameters:
      name - the file name to transform
      Returns:
      the filtered file name
    • decode

      public static String decode(String source)
      Decodes an URI-encoded String.
      Parameters:
      source - the String to decode.
      Returns:
      the decoded String.