public class FileUtil
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
static java.lang.Integer | 
BINARY_BUFFER_SIZE  | 
| Constructor and Description | 
|---|
FileUtil()  | 
| Modifier and Type | Method and Description | 
|---|---|
static java.io.File | 
createFileAndWrite(java.io.InputStream stream)
Creates file in temporary directory and writes stream to that file. 
 | 
static java.io.File | 
createPipelineFile()
Generates operationsystem temporary file with unique name. 
 | 
static FileDataHandler | 
getDatahandlerFromFile(java.io.File file)
Method creates  
DataHandler from File. | 
static FileDataHandler | 
getDatahandlerFromFile(java.io.File file,
                      java.lang.String contentType)
Method creates  
DataHandler from File. | 
static javax.activation.DataHandler | 
getDatahandlerFromStream(java.io.InputStream stream)
Method creates  
DataHandler from InputStream. | 
static java.io.File | 
getFile(java.lang.String path)
Gets file from classpath or from filesystem by files path. 
 | 
static java.io.InputStream | 
getFileAsStream(java.io.File file)
Returns files stream. 
 | 
static java.io.InputStream | 
getFileAsStream(java.lang.String path)
Gets file from classpath or from filesystem by files path and returns files stream 
 | 
static void | 
safeCloseReader(java.io.Reader reader)
Safely closes reader. 
 | 
static void | 
safeCloseStream(java.io.InputStream stream)
Safely closes inputstream. 
 | 
static void | 
safeCloseStream(java.io.OutputStream stream)
Safely closes outputstream. 
 | 
static void | 
safeCloseWriter(java.io.Writer writer)
Safely closes writer. 
 | 
static void | 
writeToFile(java.io.InputStream inStream,
           java.io.FileOutputStream targetStream)
Writes stream to FileOutputStream. 
 | 
static void | 
writeToFile(java.lang.String stringToWrite,
           java.io.FileOutputStream targetStream)
Writes string to FileOutputStream. 
 | 
static java.io.InputStream | 
zipUnpack(java.io.InputStream zipStream,
         java.lang.String fileToFindInZip)
Unpacks ZIP file and find file provided in input. 
 | 
@Loggable
public static java.io.File createPipelineFile()
                                                  throws java.io.IOException
java.io.IOException - - thrown if error occurs while creating filepublic static java.io.File getFile(java.lang.String path)
                            throws DhxException
path - - path of the file. if start with jar://, then searches from classpathDhxException - - throws if error occurs while getting filepublic static java.io.InputStream getFileAsStream(java.lang.String path)
                                           throws DhxException
path - - path of the file. if start with jar://, then searches from classpathInputStreamDhxException - - throws if error occurs while getting filepublic static java.io.InputStream getFileAsStream(java.io.File file)
                                           throws DhxException
file - - File to get its streamInputStreamDhxException - - throws if error occcurs while getting files streampublic static java.io.File createFileAndWrite(java.io.InputStream stream)
                                       throws DhxException
stream - - stream to write to fileDhxException - - thrown if error occured while creating or writing filepublic static void writeToFile(java.io.InputStream inStream,
                               java.io.FileOutputStream targetStream)
                        throws DhxException
inStream - - stream to write to filetargetStream - - FileOutputStream into which write the inStreamDhxException - - thrown if error occured while writing to filepublic static void writeToFile(java.lang.String stringToWrite,
                               java.io.FileOutputStream targetStream)
                        throws DhxException
stringToWrite - - string to write to filetargetStream - - FileOutputStream into which write the inStreamDhxException - - thrown if error occured while writing to filepublic static void safeCloseStream(java.io.InputStream stream)
stream - - stream to closepublic static void safeCloseStream(java.io.OutputStream stream)
stream - - stream to closepublic static void safeCloseReader(java.io.Reader reader)
reader - - reader to closepublic static void safeCloseWriter(java.io.Writer writer)
writer - - writer to closepublic static java.io.InputStream zipUnpack(java.io.InputStream zipStream,
                                            java.lang.String fileToFindInZip)
                                     throws DhxException
zipStream - - InputStream of ZIP filefileToFindInZip - - file to find inside ZIP fileInputStream of file foundDhxException - - throws if error occurs while unzipping of during file searchpublic static FileDataHandler getDatahandlerFromFile(java.io.File file)
DataHandler from File.file - - File to create DataHandler fromFileDataHandler created from Filepublic static FileDataHandler getDatahandlerFromFile(java.io.File file, java.lang.String contentType)
DataHandler from File.file - - File to create DataHandler fromcontentType - conent type to set for the handlerFileDataHandler created from Filepublic static javax.activation.DataHandler getDatahandlerFromStream(java.io.InputStream stream)
                                                             throws DhxException
DataHandler from InputStream.stream - - InputStream to create DataHandler fromDataHandler created from InputStreamDhxException - - throws if error occurs while creating DataHandler