public class IOUtil extends Object
Constructor and Description |
---|
IOUtil() |
Modifier and Type | Method and Description |
---|---|
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 Map<String,byte[]> |
getResources(Class<?>... classes) |
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 void |
unzipToFolder(InputStream inputStream,
File folder) |
static void |
write(File file,
byte[] fileContent) |
static void |
write(File file,
String content) |
static byte[] |
zip(Map<String,byte[]> files) |
static void |
zipDir(String dir2zip,
ZipOutputStream zos,
String root)
Create a structured zip archive recursively.
|
public static void write(File file, byte[] fileContent) throws IOException
IOException
public static byte[] generateJar(Class<?>... classes) 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
dir2zip
- zos
- root
- filenameFilter
- IOException
public static void write(File file, String content) throws IOException
IOException
public static String read(InputStream inputStream) throws IOException
inputStream
- the stream to read fromIOException
public static String read(File file) throws IOException
file
- IOException
public static void unzipToFolder(InputStream inputStream, File folder) throws IOException, FileNotFoundException
IOException
FileNotFoundException
Copyright © 2013 BonitaSoft. All Rights Reserved.