Class StreamUtils
- java.lang.Object
-
- com.levigo.jadice.server.core.util.StreamUtils
-
-
Field Summary
Fields Modifier and Type Field Description static char[]
ILLEGAL_FILENAME_CHARACTERS
Characters that are not legal as filename (control characters are filtered separately)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
createSanitizedFilename(StreamDescriptor descriptor, String fallbackFilename)
Utility method for retrieving a sanitized filename out of the data provided in the stream descriptor.static File
dumpWithUniqueName(Stream stream, File directory, String fallbackFilename)
Dump the given stream.
-
-
-
Field Detail
-
ILLEGAL_FILENAME_CHARACTERS
public static final char[] ILLEGAL_FILENAME_CHARACTERS
Characters that are not legal as filename (control characters are filtered separately)- See Also:
#see
-
-
Method Detail
-
createSanitizedFilename
public static String createSanitizedFilename(StreamDescriptor descriptor, String fallbackFilename)
Utility method for retrieving a sanitized filename out of the data provided in the stream descriptor. Definition: A sanitized name contains only a base name and an extension, but no information about paths or such.The priority for the base name is:
- base name from
StreamDescriptor.getFileName()
- base name from the
fallbackFilename
- extension that was determined in the
StreamAnalysisNode
- extension from
StreamDescriptor.getFileName()
- extension from the
fallbackFilename
- Parameters:
descriptor
- Contains the filename informationfallbackFilename
- is used when no other information was provided- Returns:
- a sanitized filename
- Since:
- 4.3.1.1
- base name from
-
dumpWithUniqueName
public static File dumpWithUniqueName(Stream stream, File directory, String fallbackFilename) throws IOException
Dump the given stream. Several considerations are made:-
The filename will be created as defined in
createSanitizedFilename(StreamDescriptor, String)
- The file will be stored in the given
directory
- If there is already another file in the given
directory
, it will be stored in a new sub-directory with thestream's UUID
.
- Parameters:
stream
- TheStream
to dumpdirectory
- The top-level directory where to store the streamfallbackFilename
- A fallback filename, seecreateSanitizedFilename(StreamDescriptor, String)
- Returns:
- The location where the file was dumped
- Throws:
IOException
- in case of an I/O error
-
The filename will be created as defined in
-
-