public class FileUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FileUtils.FileExtension
The enum File extension.
|
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
convertToBytes(Object object,
FileUtils.FileExtension extension)
Convert to bytes byte [ ].
|
static InputStream |
convertToInputStream(Object object,
FileUtils.FileExtension extension)
Convert to input stream input stream.
|
static List<URL> |
getAllLocations(String fileName)
Gets file input streams.
|
static FileContentHandler |
getFileContentMapFromZip(byte[] zipData)
Gets file content map from zip.
|
static String |
getFileExtension(String filename) |
static String |
getFileWithoutExtention(String fileName)
Gets file without extention.
|
static String |
getNetworkPackageName(String filename) |
static InputStream |
loadFileToInputStream(String fileName)
Load file to input stream input stream.
|
static <T> T |
readViaInputStream(String fileName,
Function<InputStream,T> function)
Allows to consume an input stream open against a resource with a given file name.
|
static <T> T |
readViaInputStream(URL urlFile,
Function<InputStream,T> function)
Allows to consume an input stream open against a resource with a given URL.
|
static byte[] |
toByteArray(InputStream input)
To byte array byte [ ].
|
public static <T> T readViaInputStream(String fileName, Function<InputStream,T> function)
fileName
- the file namefunction
- logic to be applied to the input streampublic static <T> T readViaInputStream(URL urlFile, Function<InputStream,T> function)
urlFile
- the url filefunction
- logic to be applied to the input streampublic static List<URL> getAllLocations(String fileName)
fileName
- the file namepublic static byte[] convertToBytes(Object object, FileUtils.FileExtension extension)
object
- the objectextension
- the extensionpublic static InputStream convertToInputStream(Object object, FileUtils.FileExtension extension)
object
- the objectextension
- the extensionpublic static InputStream loadFileToInputStream(String fileName)
fileName
- the file namepublic static byte[] toByteArray(InputStream input)
input
- the inputpublic static String getFileWithoutExtention(String fileName)
fileName
- the file namepublic static FileContentHandler getFileContentMapFromZip(byte[] zipData) throws IOException
zipData
- the zip dataIOException
- the io exceptionCopyright © 2017. All rights reserved.