public class FileUtil extends Object
FileUtils
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(String data)
Decodes a Base64 string into octets.
|
static boolean |
deleteFile(File file)
Deletes a specified File.
|
static String |
encode(byte[] data)
Encoded binary data into a Base64 string.
|
static String |
read(String fileName)
Returns the contents of the file as a string, using the system default charset encoding.
|
static byte[] |
readBytes(String fileName)
Returns the contents of the file as a byte array.
|
static String |
rtfToPlainText(String message,
String replaceLinebreaksWith)
Converts an RTF into plain text using the Swing RTFEditorKit.
|
static void |
write(String fileName,
boolean append,
byte[] bytes)
Writes a byte array to a file, creating the file if it does not exist.
|
static void |
write(String fileName,
boolean append,
String data)
Writes a string to a specified file, creating the file if it does not exist.
|
public static void write(String fileName, boolean append, String data) throws IOException
fileName
- The pathname string of the file to write to.append
- If true, the data will be added to the end of the file rather than overwriting the
file.data
- The content to write to the file.IOException
FileUtils.writeStringToFile(File, String)
public static byte[] decode(String data)
data
- The Base64 string to decode.public static String encode(byte[] data)
data
- The binary data to encode (byte array).public static void write(String fileName, boolean append, byte[] bytes) throws IOException
fileName
- The pathname string of the file to write to.append
- If true, the data will be added to the end of the file rather than overwriting the
file.bytes
- The binary content to write to the file.IOException
FileUtils.writeByteArrayToFile(File, byte[])
public static byte[] readBytes(String fileName) throws IOException
fileName
- The pathname string of the file to read from.IOException
FileUtils.readFileToByteArray(File)
public static String read(String fileName) throws IOException
fileName
- The pathname string of the file to read from.IOException
FileUtils.readFileToString(File)
public static boolean deleteFile(File file) throws SecurityException
file
- The File to delete.SecurityException
public static String rtfToPlainText(String message, String replaceLinebreaksWith) throws IOException, BadLocationException
message
- The RTF message to convert.replaceLinebreaksWith
- If not null, any line breaks in the converted message will be replaced with this
string.IOException
BadLocationException