|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.util.FileUtils
public class FileUtils
Utility class used for file manipulation operations.
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static boolean |
copyFile(File fromFile,
File toFile,
boolean overwrite)
Copy file. |
static boolean |
copyFile(String fromPath,
String toPath,
boolean overwrite)
Copy file. |
static void |
delete(File file)
Simply calls the delete() method of the provided file object. |
static void |
delete(File file,
Log log)
Simply calls the delete() method of the provided file object. |
static void |
delete(String path)
Simply calls the delete() method of the provided file object. |
static void |
delete(String path,
Log log)
Simply calls the delete() method of the provided file object. |
static void |
deleteRecursively(File toDelete)
Deletes the provided File . |
static void |
deleteRecursively(String toDelete)
Convenience method that delegates to deleteRecursively(File) . |
static String |
loadFile(File file)
Loads the specified file and returns its content as String. |
static String |
loadFile(File file,
String encoding)
Loads the specified file and returns its content as String. |
static String |
loadFile(String file)
Loads the specified file and returns its content as String. |
static void |
mkdir(File file)
Simply calls the mkdir() method of the provided file object. |
static void |
mkdir(File file,
Log log)
Simply calls the mkdir() method of the provided file object. |
static void |
mkdir(String path)
Simply calls the mkdir() method of the provided file object. |
static void |
mkdir(String path,
Log log)
Simply calls the mkdir() method of the provided file object. |
static void |
mkdirs(File file)
Simply calls the mkdirs() method of the provided file object. |
static void |
mkdirs(File file,
Log log)
Simply calls the mkdirs() method of the provided file object. |
static void |
mkdirs(String path)
Simply calls the mkdirs() method of the provided file object. |
static void |
mkdirs(String path,
Log log)
Simply calls the mkdirs() method of the provided file object. |
static byte[] |
readInputStream(InputStream is)
Reads the provided input stream and returns it as an array of bytes. |
static void |
renameTo(File from,
File to)
Simply calls the renameTo() method of the provided file object. |
static void |
renameTo(File from,
File to,
Log log)
Simply calls the renameTo() method of the provided file object. |
static void |
renameTo(String from,
String to)
Simply calls the renameTo() method of the provided file object. |
static void |
renameTo(String from,
String to,
Log log)
Simply calls the renameTo() method of the provided file object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static String loadFile(String file) throws Exception
file
- the path to the file to load.
Exception
- if an I/O error occurs.public static String loadFile(File file) throws Exception
file
- the file to load.
Exception
- if an I/O error occurs.public static String loadFile(File file, String encoding) throws Exception
file
- the file to load.encoding
- the name of the encoding to use, if this is null the platform
default encoding will be used.
Exception
- if an I/O error occurs.public static byte[] readInputStream(InputStream is) throws IOException
InputStream
object.
is
- the input stream to read
IOException
- if reading error occurs.public static void delete(File file, Log log)
file
- the file to deletelog
-
IllegalArgumentException
- - if either of the parameters is null or the specified file
does not exists.
SecurityException
- if the file could not be deleted.public static void delete(String path, Log log)
path
- the file to deletelog
-
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the file could not be deleted.
NullPointerException
- if the provided path argument is null.public static void mkdirs(File file, Log log)
file
- the directory to createlog
-
IllegalArgumentException
- - if either of the parameters is null
SecurityException
- if the directories could not be createdpublic static void mkdirs(String path, Log log)
path
- the directory to createlog
-
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the directories could not be created
NullPointerException
- if the provided path argument is null.public static void mkdir(File file, Log log)
file
- the directory to createlog
-
IllegalArgumentException
- - if either of the parameters is null
SecurityException
- if the directories could not be createdpublic static void mkdir(String path, Log log)
path
- the directory to createlog
-
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the directory could not be created
NullPointerException
- if the provided path argument is null.public static void renameTo(File from, File to, Log log)
from
- the file to renameto
- the name of the file to setlog
-
IllegalArgumentException
- - if either of the parameters is null or the specified file
does not renamed.
SecurityException
- if the file could not be deleted.public static void renameTo(String from, String to, Log log)
from
- the file to renameto
- the name of the file to setlog
-
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the file could not be renamed.
NullPointerException
- if the provided path argument is null.public static void delete(File file) throws Exception
file
- the file to delete
Exception
- if the file cannot be deleted.
IllegalArgumentException
- - if either of the parameters is null or the specified file
does not exists.
SecurityException
- if the file could not be deleted.public static void deleteRecursively(File toDelete) throws Exception
File
. If the File
denotes a
directory it will be deleted recursively whit all of the files it
contains. Additionally the returned value is checked and an exception is
thrown if the file could not be deleted.
file
- the file to delete
Exception
- if the file cannot be deleted.
IllegalArgumentException
- - if either of the parameters is null or the specified file
does not exists.
SecurityException
- if the file could not be deleted.public static void deleteRecursively(String toDelete) throws Exception
deleteRecursively(File)
.
toDelete
- the file to delete
Exception
- if the file cannot be deleted.public static void delete(String path) throws Exception
path
- the file to delete
Exception
- if the file could not be deleted.
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the file could not be deleted.
NullPointerException
- if the provided path argument is null.public static void mkdirs(File file) throws Exception
file
- the directory to create
Exception
- if the directories could not be created.
IllegalArgumentException
- - if either of the parameters is null
SecurityException
- if the directories could not be createdpublic static void mkdirs(String path) throws Exception
path
- the directory to create
Exception
- if the directories could not be created.
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the directories could not be created
NullPointerException
- if the provided path argument is null.public static void mkdir(File file) throws Exception
file
- the directory to create
Exception
- if the directory could not be created.
IllegalArgumentException
- - if either of the parameters is null
SecurityException
- if the directories could not be createdpublic static void mkdir(String path) throws Exception
path
- the directory to create
Exception
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the directory could not be created
NullPointerException
- if the provided path argument is null.public static void renameTo(File from, File to) throws Exception
from
- the file to renameto
- the name of the file to set
Exception
- if the file could not be renamed.
IllegalArgumentException
- - if either of the parameters is null or the specified file
does not renamed.
SecurityException
- if the file could not be renamed.public static void renameTo(String from, String to) throws Exception
from
- the file to renameto
- the name of the file to set
Exception
- if the file could not be renamed.
IllegalArgumentException
- - if either of the parameters is null.
SecurityException
- if the file could not be renamed.
NullPointerException
- if the provided path argument is null.public static boolean copyFile(String fromPath, String toPath, boolean overwrite) throws Exception
com.ibm.di.function.UserFunctions.copyFile(String, String, boolean)
method.
fromPath
- The source filetoPath
- The destination fileoverwrite
- Specify true if destination should be overwritten.
Exception
public static boolean copyFile(File fromFile, File toFile, boolean overwrite) throws Exception
com.ibm.di.function.UserFunctions.copyFile(File, File, boolean)
method.
fromFile
- The source filetoFile
- The destination fileoverwrite
- Specify true if destination should be overwritten.
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |