public class IOUtil extends Object
Constructor and Description |
---|
IOUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
append(File file,
String text)
Appends the specified text to the specified file.
|
static void |
append(File file,
String text,
String charsetName)
Appends the specified text to the specified file in the charset specified by the charsetName.
|
static long |
copy(InputStream is,
OutputStream os)
Copies the specified InputStream to the specified OutputStream.
|
static void |
copyFolder(File sourceLocation,
File targetLocation)
Copies the specified file or folder (including its contents) to the specified target location.
|
static boolean |
delete(File file)
Deletes the specified file.
|
static void |
deleteFolder(File folder)
Deletes the specified folder, and any contents it may contain.
|
static String |
read(File file)
Reads the specified file and returns the content as a String.
|
static String |
read(File file,
String charsetName)
Reads the specified file and returns the content as a String in the charset specified by the charsetName.
|
static Serializable |
readObj(File file)
Reads and deserializes the content of the specified file, returning it as a Serializable Object.
|
static void |
report(String message)
Formats and prints the specified error message to System.err.
|
static String |
stackTraceToString(Throwable e)
Returns a String representation of the stracktrace generated by the specified Throwable.
|
static String |
toString(InputStream is)
Returns the data of the specified InputStream as a String.
|
static void |
write(File file,
String text)
Writes the specified text to the specified file, overwriting any content already in the file.
|
static void |
write(File file,
String text,
String charsetName)
Writes the specified text to the specified file in the charset specified by the charsetName, overwriting any content already in the file.
|
static void |
writeObj(File file,
Serializable s)
Serializes and writes the specified Serializable object to the specified file.
|
static void |
zipFolder(File input,
File output)
Zips the specified input folder (including contents) to specified output zipfile.
|
public static void report(String message)
public static boolean delete(File file)
public static void write(File file, String text) throws IOException
IOException
public static void write(File file, String text, String charsetName) throws IOException
IOException
public static void append(File file, String text) throws IOException
IOException
public static void append(File file, String text, String charsetName) throws IOException
IOException
public static String read(File file) throws IOException
IOException
public static String read(File file, String charsetName) throws IOException
IOException
public static void writeObj(File file, Serializable s) throws IOException
IOException
public static Serializable readObj(File file) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static long copy(InputStream is, OutputStream os)
public static String toString(InputStream is) throws IOException
IOException
public static String stackTraceToString(Throwable e)
public static void deleteFolder(File folder)
public static void copyFolder(File sourceLocation, File targetLocation) throws IOException
IOException
public static void zipFolder(File input, File output) throws IOException
IOException