public class FileUtils extends Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
loadAsBytes(String propertyName,
File file)
Loading an array of bytes from a file.
|
static StringList |
loadAsLines(String propertyName,
File file)
Load a file to a list of Strings, using the Files.readAllLines(File,Charset) and the Charset.defaultCharset().
|
static String |
loadAsString(String propertyName,
File file)
Loads a file into a string using the InputStreamReader with a UTF_8 Charset and a default buffersize of 2048.
|
static String |
loadAsString(String propertyName,
File file,
int bufferSize,
String charsetName)
Loads a file into a string using the InputStreamReader with a charset and buffersize.
|
static String |
loadAsString(String propertyName,
File file,
String charsetName)
Loads a file into a string using the InputStreamReader with a charset and a default buffersize of 2048.
|
static void |
setFileLastModified(File file,
long time)
Calls File.setLastModified(long time).
|
static void |
touch(File file)
Sets the a file last modified timestamp to now.
|
public static final String loadAsString(String propertyName, File file) throws PropertyException
propertyName
- the name of the property from where the loadAsString has originated.file
- the file to readPropertyException
- if File is not found or unreadable, or the charsetName is invalid.loadAsString(String, File, int, String)
public static final String loadAsString(String propertyName, File file, String charsetName) throws PropertyException
propertyName
- the name of the property from where the loadAsString has originated.file
- the file to readcharsetName
- a valid charsetName for the encoding.PropertyException
- if File is not found or unreadable, or the charsetName is invalid.loadAsString(String, File, int, String)
public static final String loadAsString(String propertyName, File file, int bufferSize, String charsetName) throws PropertyException
propertyName
- the name of the property from where the loadAsString has originated.file
- the file to read.bufferSize
- the buffer size to load the file with using the InputStreamReader.read(byte[],int,int) method, if bufferSize is less than 1, 2048 is used.charsetName
- a valid charsetName for the encoding.PropertyException
- if File is not found or unreadable, or the charsetName is invalid.public static final byte[] loadAsBytes(String propertyName, File file) throws PropertyException
propertyName
- the name of property, using this method.file
- the file to load the bytes fromPropertyException
- if file not found or unreadable.public static final StringList loadAsLines(String propertyName, File file) throws PropertyException
propertyName
- the name of property, using this method.file
- the filePropertyException
- if the file could not be loaded.public static void touch(File file) throws IOException
file
- the file to touch.IOException
- if the file is null
, or any SecurityException is thrown.File.setLastModified(long)
,
setFileLastModified(File, long)
public static void setFileLastModified(File file, long time) throws IOException
file
- the file whose modified time is to be set, if less than zero, current time milliseconds is used.time
- the time to which the last modified time is to be set. If this is -1, the current time is used.IOException
File.setLastModified(long)