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.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 final 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
public static final <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
public static final <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
public static final <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
public static final 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
public static final <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
public static final <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> org.primefaces.model.StreamedContent getStreamedContent(T entity)
StreamedContent
for the given IFileProviding
entityentity
- for which to return a StreamedContent
StreamedContent
of the given IFileProviding
entity or null
if the entity is
null
public static final 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.public static final byte[] getData(org.primefaces.model.UploadedFile upload) throws Exception, OutOfMemoryError
UploadedFile
as a byte arrayupload
- UploadedFile
holding the dataException
OutOfMemoryError
- if Java Virtual Machine is out of memorypublic static final String getContentType(File file)
public static final String generateFileName(Datenquelle source)
source
- Datenquelle
String
file name of the given data sourcepublic static final String getExtension(Datenquelle source)
source
- Datenquelle
String
file extensionpublic static final String getContentType(String fileName)
public static final boolean isImageFile(String fileName)
Copyright © 2019 XIMA MEDIA GmbH. All rights reserved.