public class FileUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ENCODING |
static String |
FILENAME_GENERAL_ZIP |
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> |
createZipFile(List<T> entities,
File outDir)
Packs the files of the given entities into one zip file which will be placed in the specified output directory
|
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> |
createZipFile(List<T> entities,
File outDir,
String zipFileName)
Packs the files of the given entities into one zip file which will be placed in the specified output directory
|
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> |
createZipFileFromDataSources(List<Datenquelle> sources,
File outDir,
String zipFileName)
Packs the contents of the given data sources into one zip file which will be placed in the specified output
directory
|
static File |
createZipFileFromFiles(List<File> files,
File outDir,
String zipFileName)
Packs the given files one zip file which will be placed in the specified output directory
|
static String |
generateFileName(Datenquelle source)
Generates a file name for the given data source
|
static String |
getContentType(File file)
Returns the content type of the given file
|
static String |
getContentType(String fileName)
Returns the content type of the file by its filename
|
static byte[] |
getData(org.primefaces.model.file.UploadedFile upload)
Returns the data of the
UploadedFile as a byte array |
static String |
getExtension(Datenquelle source)
Returns the file extension for the given data source
|
static File |
getFile(Datenquelle source,
File outDir)
Generates a
File for a given data source |
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> |
getFile(T entity,
File outDir)
Gets the
File from an IFileProviding entity placed within the specified output directory |
static org.primefaces.model.StreamedContent |
getStreamedContent(List<Datenquelle> sources,
String zipFileName)
Generates
StreamedContent from the given List of data sources. |
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> |
getStreamedContent(T entity)
Gets a
StreamedContent for the given IFileProviding entity |
static String |
getStyleClass(String fileName) |
static boolean |
isImageFile(String fileName) |
public static final String ENCODING
public static final String FILENAME_GENERAL_ZIP
public static File getFile(Datenquelle source, File outDir) throws IOException
File
for a given data sourcesource
- Datenquelle
for which a file should be generatedoutDir
- File
output directory where resulting file should be placedFile
of the given data sourceIOException
- on errors during writing the filepublic static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> File getFile(T entity, File outDir) throws IOException
File
from an IFileProviding
entity placed within the specified output directoryentity
- IFileProviding
holding the desired fileoutDir
- File
output directory where resulting file should be placedFile
of the given entityIOException
- on errors during writing the filepublic static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> File createZipFile(List<T> entities, File outDir) throws IOException
entities
- IFileProviding
entities that should be packed into one zip archiveoutDir
- File
output directory where the resulting zip file will be placedFile
in zip format containing all the files of the entitiesIOException
- on errors during creating the zip filepublic static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> File createZipFile(List<T> entities, File outDir, String zipFileName) throws IOException
entities
- IFileProviding
entities that should be packed into one zip archiveoutDir
- File
output directory where the resulting zip file will be placedzipFileName
- String
name of the resulting zip fileFile
in zip format containing all the files of the entitiesIOException
- on errors during creating the zip filepublic static File createZipFileFromFiles(List<File> files, File outDir, String zipFileName) throws IOException
files
- List
files that should be packed into one zip archiveoutDir
- File
output directory where the resulting zip file will be placedzipFileName
- String
name of the resulting zip fileFile
in zip format containing all the filesIOException
- on errors during creating the zip filepublic static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> File createZipFileFromDataSources(List<Datenquelle> sources, File outDir, String zipFileName) throws IOException
sources
- IFileProviding
data sources that should be packed into one zip archiveoutDir
- File
output directory where the resulting zip file will be placedzipFileName
- String
name of the resulting zip fileFile
in zip format containing all the content files of the data sourcesIOException
- on errors during creating the zip filepublic static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> org.primefaces.model.StreamedContent getStreamedContent(T entity)
StreamedContent
for the given IFileProviding
entityE
- Type of the file data entity.T
- Type of the class that provides the file.entity
- for which to return a StreamedContent
StreamedContent
of the given IFileProviding
entity or null
if the entity is
null
public static org.primefaces.model.StreamedContent getStreamedContent(List<Datenquelle> sources, String zipFileName) throws Exception
StreamedContent
from the given List of data sources. If this list contains only a single entry
the StreamedContent
for this data source will be returned. If the list contains more than one entry the
data sources will be packed into a zip file with the specified filename and the generated StreamedContent
of the zip file will be returned.sources
- List
of the data sources to generate StreamedContent
forzipFileName
- String
name of the resulting zip file if more than one data source is contained within
the given data source listStreamedContent
of all the marked model data sourcesException
- on errors during creating the StreamedContent
public static byte[] getData(org.primefaces.model.file.UploadedFile upload) throws Exception, OutOfMemoryError
UploadedFile
as a byte arrayupload
- UploadedFile
holding the dataException
- on errors during reading the UploadedFile
OutOfMemoryError
- if Java Virtual Machine is out of memorypublic static String getContentType(File file)
public static String generateFileName(Datenquelle source)
source
- Datenquelle
String
file name of the given data sourcepublic static String getExtension(Datenquelle source)
source
- Datenquelle
String
file extensionpublic static String getContentType(String fileName)
public static boolean isImageFile(String fileName)
Copyright © 2021 XIMA MEDIA GmbH. All rights reserved.