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[] |
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
IOExceptionpublic static Map<String,byte[]> getResources(Class<?>... classes) throws IOException
IOExceptionpublic static byte[] getClassData(Class<?> clazz) throws IOException
IOExceptionpublic static byte[] generateJar(Map<String,byte[]> resources) throws IOException
IOExceptionpublic 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
IOExceptionpublic static boolean deleteDir(File dir, int attempts, long sleepTime) throws IOException
IOExceptionpublic static boolean deleteFile(File f, int attempts, long sleepTime)
public static byte[] zip(Map<String,byte[]> files) throws IOException
IOExceptionpublic static void zipDir(String dir2zip, ZipOutputStream zos, String root) throws IOException
IOExceptionpublic static String read(InputStream inputStream)
inputStream - the stream to read frompublic static String read(File file) throws IOException
file - the file to readIOExceptionpublic static void unzipToFolder(InputStream inputStream, File outputFolder) throws IOException
IOExceptionpublic static void writeContentToFile(String content, File outputFile) throws IOException
IOExceptionpublic static void writeContentToFileOutputStream(String content, FileOutputStream fileOutput) throws IOException
IOExceptionpublic static void write(File file, byte[] fileContent) throws IOException
IOExceptionpublic static byte[] getContent(File file) throws IOException
IOExceptionpublic static byte[] marshallObjectToXML(Object jaxbModel, URL schemaURL) throws JAXBException, IOException, SAXException
JAXBExceptionIOExceptionSAXExceptionpublic static <T> T unmarshallXMLtoObject(byte[] xmlObject,
Class<T> objectClass,
URL schemaURL)
throws JAXBException,
IOException,
SAXException
JAXBExceptionIOExceptionSAXExceptionCopyright © 2018 Bonitasoft S.A.. All rights reserved.