public final class IOHelper
extends java.lang.Object
Constructor and Description |
---|
IOHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
copyFile(java.io.File fromFile,
java.io.File toFile,
boolean overwrite)
Copies a file to another location/file.
|
static boolean |
copyFile(java.lang.String fromName,
java.lang.String toName,
boolean overwrite)
Copies a file to another location/file.
|
static void |
createDirectoryTreeForFile(java.lang.String file)
Creates the complete directory structure for a complete
FILE pathname.
|
static java.lang.String |
createDirectoryTreeForFolder(java.lang.String folder)
Creates the complete directory structure for a complete
FOLDER pathname.
|
static boolean |
deleteDirectory(java.io.File dir)
Deletes all files and subdirectories under dir.
|
static boolean |
deleteDirectory(java.lang.String pathname)
Deletes all files and subdirectories under dir.
|
static boolean |
deleteFile(java.lang.String pathname)
Deletes a file.
|
static boolean |
fileOrDirectoryExists(java.lang.String pathname)
Determines if a file or directory exists.
|
static boolean |
isDirectory(java.lang.String pathname)
Determines if a directory exists.
|
static boolean |
isFile(java.lang.String pathname)
Determines if a file exists.
|
static boolean |
isTheSameFile(java.lang.String pathname1,
java.lang.String pathname2)
Determines if two filename paths refer to the same file.
|
static java.lang.String |
readTxtFile(java.io.File f)
Reads a text file into a string.
|
static java.lang.String |
readTxtFile(java.lang.String pathname)
Reads a text file into a string.
|
static void |
saveTxtFile(java.io.File f,
java.lang.String data,
boolean append)
Saves a string to a text file.
|
static void |
saveTxtFile(java.lang.String pathname,
java.lang.String data,
boolean append)
Saves a string to a text file.
|
public static java.lang.String createDirectoryTreeForFolder(java.lang.String folder) throws java.io.IOException
folder
- The folder pathname.
java.io.IOException
public static void createDirectoryTreeForFile(java.lang.String file) throws java.io.IOException
file
- The file pathname.
java.io.IOException
public static boolean isTheSameFile(java.lang.String pathname1, java.lang.String pathname2) throws java.io.IOException
pathname1
- The first pathname.pathname2
- The second pathname.
true
if two filename paths refer
to the same file.
java.io.IOException
- public static boolean fileOrDirectoryExists(java.lang.String pathname)
pathname
- The file or directory pathname.
true
if it exists.public static boolean isFile(java.lang.String pathname)
pathname
- The file to check.
true
if it exists.public static boolean isDirectory(java.lang.String pathname)
pathname
- The directory pathname.
true
if it exists.public static void saveTxtFile(java.lang.String pathname, java.lang.String data, boolean append) throws java.io.IOException
pathname
- The pathname to the file.data
- The string to be saved.append
- true
if the string is to be appended
to the end of existing text.
java.io.IOException
public static void saveTxtFile(java.io.File f, java.lang.String data, boolean append) throws java.io.IOException
f
- The file.data
- The string to save.append
- true
if the string is to be appended
to the end of existing text.
java.io.IOException
public static java.lang.String readTxtFile(java.lang.String pathname) throws java.io.IOException
pathname
- The path to the text file.
java.io.IOException
public static java.lang.String readTxtFile(java.io.File f) throws java.io.IOException
f
- The file.
java.io.IOException
public static boolean deleteDirectory(java.io.File dir)
true
if all deletions were successful.
If a deletion fails, the method stops attempting
to delete and returns false
.
dir
- The directory to delete from.
true
if all deletions were successful.public static boolean deleteDirectory(java.lang.String pathname)
true
if all deletions were successful.
If a deletion fails, the method stops attempting
to delete and returns false
.
pathname
- The path to the directory.
true
if all deletions were successful.public static boolean deleteFile(java.lang.String pathname)
pathname
- The pathname to the file.
true
if successful.public static boolean copyFile(java.lang.String fromName, java.lang.String toName, boolean overwrite) throws java.io.IOException
fromName
- The file to copy from.toName
- The file to copy to.overwrite
- true
to overwrite if the file already
exists.
true
if file copied or
false
if not (possibly the file existed
and 'overwrite' was not set).
java.io.IOException
public static boolean copyFile(java.io.File fromFile, java.io.File toFile, boolean overwrite) throws java.io.IOException
fromFile
- The file to copy from.toFile
- The file to copy to.overwrite
- true
to overwrite if the file already
exists.
true
if file copied or
false
if not (possibly the file existed
and 'overwrite' was not set).
java.io.IOException