public class FilenameUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static char[] |
RESERVED_FILENAME_CHARACTERS
Reserved characters
|
Constructor and Description |
---|
FilenameUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getName(java.lang.String path)
This is a duplication of the algorithm and functionality
available in commons io FilenameUtils.
|
static java.lang.String |
normalize(java.lang.String name)
Scans the given file name for reserved characters on different OSs and
file systems and returns a sanitized version of the name with the
reserved chars replaced by their hexadecimal value.
|
public static final char[] RESERVED_FILENAME_CHARACTERS
public static java.lang.String normalize(java.lang.String name)
why?.zip
will be converted into why%3F.zip
name
- the file name to be normalized - NOT NULLjava.lang.IllegalArgumentException
- if name is nullpublic static java.lang.String getName(java.lang.String path)
The goal of this is to get a filename from a path. The package parsers and some other embedded doc extractors could put anything into Metadata.RESOURCE_NAME_KEY.
If a careless client used that filename as if it were a filename and not a path when writing embedded files, bad things could happen. Consider: "../../../my_ppt.ppt".
Consider using this in combination with normalize(String)
.
path
- path to stripCopyright © 2010 - 2020 Adobe. All Rights Reserved