Package org.bonitasoft.engine.commons.io
Class IOUtil
java.lang.Object
org.bonitasoft.engine.commons.io.IOUtil
- Author:
- Elias Ricken de Medeiros, Matthieu Chaffotte, Celine Souchet
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]addJarEntry(byte[] jarToUpdate, String entryName, byte[] entryContent) static booleanstatic FilecreateTempDirectory(URI directoryPath) static booleanstatic booleanstatic booleandeleteFile(File file, int attempts, long sleepTime) static byte[]generateJar(Class<?>... classes) static byte[]generateJar(Map<String, byte[]> resources) static byte[]generateZip(Map<String, byte[]> resources) static byte[]getAllContentFrom(File file) Equivalent togetAllContentFrom(new FileInputStream(file));static byte[]Return the whole underlying stream content into a single String.static byte[]getAllContentFrom(URL url) Return the whole underlying stream content into a single String.static byte[]getBytes(ZipInputStream zipInputstream) getClassNameList(byte[] jarContent) static StringgetContentTypeForIcon(String iconFilename) static Optional<byte[]>getFileContent(String fileName) return the content of the file from the classpath, the file must be at the root of the classpathstatic byte[]getPropertyAsString(Properties prop, String comment) getResources(Class<?>... classes) static byte[]getZipEntryContent(String entryName, byte[] zipFile) static byte[]getZipEntryContent(String entryName, InputStream inputStream) static Stringmd5(byte[] content) static StringRead the contents of the given file.static Stringread(InputStream inputStream) Read the contents from the given FileInputStream.static StringreadResource(String fileName) static byte[]toByteArray(Document document) unzip(byte[] zipFile) static voidupdatePropertyValue(File propertiesFile, Map<String, String> pairs) static voidstatic voidstatic voidstatic byte[]static byte[]
-
Field Details
-
TMP_DIRECTORY
-
MIMETYPES_FILE_TYPE_MAP
public static final javax.activation.MimetypesFileTypeMap MIMETYPES_FILE_TYPE_MAP -
FILE_ENCODING
- See Also:
-
-
Method Details
-
getClassNameList
- Throws:
IOException
-
write
- Throws:
IOException
-
generateJar
- Throws:
IOException
-
getResources
- Throws:
IOException
-
generateJar
- Throws:
IOException
-
generateZip
- Throws:
IOException
-
getAllContentFrom
Return the whole underlying stream content into a single String. Warning: the whole content of stream will be kept in memory!! Use with care!- Parameters:
in- the stream to read- Returns:
- the whole content of the stream in a single String.
- Throws:
IOException- if an I/O exception occurs
-
read
Read the contents from the given FileInputStream. Return the result as a String.- Parameters:
inputStream- the stream to read from- Returns:
- the content read from the inputStream, as a String
-
read
Read the contents of the given file.- Parameters:
file-- Throws:
IOException
-
getAllContentFrom
Equivalent togetAllContentFrom(new FileInputStream(file));- Parameters:
file- the file to read- Returns:
- the whole content of the file in a single String.
- Throws:
IOException- If an I/O exception occurs
-
getAllContentFrom
Return the whole underlying stream content into a single String. Warning: the whole content of stream will be kept in memory!! Use with care!- Parameters:
url- the URL to read- Returns:
- the whole content of the stream in a single String.
- Throws:
IOException- if an I/O exception occurs
-
deleteDir
- Throws:
IOException
-
deleteDir
- Throws:
IOException
-
deleteFile
-
writeFile
- Throws:
IOException
-
zip
- Throws:
IOException
-
zip
- Throws:
IOException
-
unzip
- Throws:
IOException
-
getZipEntryContent
public static byte[] getZipEntryContent(String entryName, InputStream inputStream) throws IOException - Throws:
IOException
-
getBytes
- Throws:
IOException
-
getZipEntryContent
- Throws:
IOException
-
toByteArray
- Throws:
IOExceptionTransformerException
-
addJarEntry
public static byte[] addJarEntry(byte[] jarToUpdate, String entryName, byte[] entryContent) throws IOException - Throws:
IOException
-
getPropertyAsString
- Throws:
IOException
-
readResource
- Throws:
IOException
-
md5
- Throws:
NoSuchAlgorithmException
-
writeMD5
- Throws:
NoSuchAlgorithmExceptionIOException
-
checkMD5
- Throws:
NoSuchAlgorithmException
-
updatePropertyValue
public static void updatePropertyValue(File propertiesFile, Map<String, String> pairs) throws IOException- Throws:
IOException
-
getContentTypeForIcon
-
getFileContent
return the content of the file from the classpath, the file must be at the root of the classpath- Parameters:
fileName- name of the file- Returns:
- the optional, or empty if there is no file with that name
- Throws:
IOException- when we are unable to read the file from the classpath
-
createTempDirectory
-