public class IOUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FILE_ENCODING |
static String |
TMP_DIRECTORY |
Constructor and Description |
---|
IOUtil() |
Modifier and Type | Method and Description |
---|---|
static File |
createTempDirectory(URI directoryPath) |
static boolean |
deleteDir(File dir) |
static boolean |
deleteDir(File dir,
int attempts,
long sleepTime) |
static boolean |
deleteFile(File f,
int attempts,
long sleepTime) |
static byte[] |
generateJar(Class<?>... classes) |
static byte[] |
generateJar(Map<String,byte[]> resources) |
static byte[] |
generateJar(String className,
String... content) |
static byte[] |
getAllContentFrom(File file)
Equivalent to
getAllContentFrom(new
FileInputStream(file)) ; |
static byte[] |
getAllContentFrom(InputStream in)
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[] |
getClassData(Class<?> clazz) |
static byte[] |
getContent(File file) |
static Map<String,byte[]> |
getResources(Class<?>... classes) |
static byte[] |
marshallObjectToXML(Object jaxbModel,
URL schemaURL) |
static String |
read(File file)
Read the contents of the given file.
|
static String |
read(InputStream inputStream)
Read the contents from the given FileInputStream.
|
static <T> T |
unmarshallXMLtoObject(byte[] xmlObject,
Class<T> objectClass,
URL schemaURL) |
static void |
unzipToFolder(InputStream inputStream,
File outputFolder) |
static void |
write(File file,
byte[] fileContent) |
static void |
writeContentToFile(String content,
File outputFile) |
static void |
writeContentToFileOutputStream(String content,
FileOutputStream fileOutput) |
static byte[] |
zip(Map<String,byte[]> files) |
static void |
zipDir(String dir2zip,
ZipOutputStream zos,
String root)
Create a structured zip archive recursively.
|
public static final String TMP_DIRECTORY
public static final String FILE_ENCODING
public static byte[] generateJar(Class<?>... classes) throws IOException
IOException
public static byte[] generateJar(String className, String... content) throws IOException
IOException
public static Map<String,byte[]> getResources(Class<?>... classes) throws IOException
IOException
public static byte[] getClassData(Class<?> clazz) throws IOException
IOException
public static byte[] generateJar(Map<String,byte[]> resources) throws IOException
IOException
public static byte[] getAllContentFrom(InputStream in) throws IOException
in
- the stream to readIOException
- if an I/O exception occurspublic static byte[] getAllContentFrom(File file) throws IOException
getAllContentFrom(new
FileInputStream(file))
;file
- the file to readIOException
- If an I/O exception occurspublic static byte[] getAllContentFrom(URL url) throws IOException
url
- the URL to readIOException
- if an I/O exception occurspublic static boolean deleteDir(File dir) throws IOException
IOException
public static boolean deleteDir(File dir, int attempts, long sleepTime) throws IOException
IOException
public static boolean deleteFile(File f, int attempts, long sleepTime)
public static byte[] zip(Map<String,byte[]> files) throws IOException
IOException
public static void zipDir(String dir2zip, ZipOutputStream zos, String root) throws IOException
IOException
public static String read(InputStream inputStream)
inputStream
- the stream to read frompublic static String read(File file) throws IOException
file
- the file to readIOException
public static void unzipToFolder(InputStream inputStream, File outputFolder) throws IOException
IOException
public static void writeContentToFile(String content, File outputFile) throws IOException
IOException
public static void writeContentToFileOutputStream(String content, FileOutputStream fileOutput) throws IOException
IOException
public static void write(File file, byte[] fileContent) throws IOException
IOException
public static byte[] getContent(File file) throws IOException
IOException
public static byte[] marshallObjectToXML(Object jaxbModel, URL schemaURL) throws JAXBException, IOException, SAXException
JAXBException
IOException
SAXException
public static <T> T unmarshallXMLtoObject(byte[] xmlObject, Class<T> objectClass, URL schemaURL) throws JAXBException, IOException, SAXException
JAXBException
IOException
SAXException
Copyright © 2020 Bonitasoft S.A. All rights reserved.