public final class FileUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
createBackup(java.lang.String fullFileName)
Creates a backup file.
|
static boolean |
exists(java.lang.String fullFileName)
Tests whether a file exists.
|
static java.lang.String |
getFullPathOfResoruce(java.lang.String resourceName)
Returns full path of a resource.
|
static java.lang.String |
read(java.lang.String fullFileName)
Reads a text file using the default platform char set.
|
static java.lang.String |
read(java.lang.String fullFileName,
java.nio.charset.Charset encoding)
Reads a text file using the given char set.
|
static byte[] |
readBinary(java.lang.String fullFileName)
Reads a binary file.
|
static java.lang.String |
readUTF8(java.lang.String fullFileName)
Reads a text file in a UTF-8 Char set.
|
static void |
write(java.lang.String fullFileName,
byte[] content)
Writes a binary file.
|
static void |
write(java.lang.String fullFileName,
java.lang.String content)
Writes a text file using the default platform char set.
|
static void |
write(java.lang.String fullFileName,
java.lang.String content,
java.nio.charset.Charset encoding)
Writes a text file using the given char set.
|
static void |
writeUTF8(java.lang.String fullFileName,
java.lang.String content)
Writes a text file using the default platform char set.
|
public static java.lang.String read(java.lang.String fullFileName)
throws java.io.IOException
fullFileName - Path of the file.java.io.IOException - Exception with the error.public static java.lang.String readUTF8(java.lang.String fullFileName)
throws java.io.IOException
fullFileName - Path of the file.java.io.IOException - Exception with the error.public static java.lang.String read(java.lang.String fullFileName,
java.nio.charset.Charset encoding)
throws java.io.IOException
fullFileName - Path of the file.encoding - Char setjava.io.IOException - Exception with the error.public static byte[] readBinary(java.lang.String fullFileName)
throws java.io.IOException
fullFileName - Path of the file.java.io.IOException - Exception with the error.public static void write(java.lang.String fullFileName,
java.lang.String content)
throws java.io.IOException
fullFileName - Path of the file.content - String with the content of the file.java.io.IOException - Exception with the error.public static void write(java.lang.String fullFileName,
byte[] content)
throws java.io.IOException
fullFileName - Path of the file.content - Binary content of the file.java.io.IOException - Exception with the error.public static void writeUTF8(java.lang.String fullFileName,
java.lang.String content)
throws java.io.IOException
fullFileName - Path of the file.content - String with the content of the file.java.io.IOException - Exception with the error.public static void write(java.lang.String fullFileName,
java.lang.String content,
java.nio.charset.Charset encoding)
throws java.io.IOException
fullFileName - Path of the file.content - String with the content of the file.encoding - Char setjava.io.IOException - Exception with the error.public static boolean exists(java.lang.String fullFileName)
fullFileName - Path of the file.public static java.lang.String createBackup(java.lang.String fullFileName)
fullFileName - Path of the file.fullFileName if the file doesn't exist (no backup is made). null
if it could not create a backup file.public static java.lang.String getFullPathOfResoruce(java.lang.String resourceName)
resourceName - Resource namenull if the given resourceName is not found in the current thread's ClassLoader.