|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IFileOp
Wraps some common File
operations on files and folders.
Method Summary | |
---|---|
void |
copyFile(java.io.File source,
java.io.File dest)
Copies a binary file. |
boolean |
delete(java.io.File file)
Invokes File.delete() on the given file . |
void |
deleteFileOrFolder(java.io.File fileOrFolder)
Helper to delete a file or a directory. |
boolean |
exists(java.io.File file)
Invokes File.exists() on the given file . |
boolean |
isDirectory(java.io.File file)
Invokes File.isDirectory() on the given file . |
boolean |
isFile(java.io.File file)
Invokes File.isFile() on the given file . |
boolean |
isSameFile(java.io.File file1,
java.io.File file2)
Checks whether 2 binary files are the same. |
long |
lastModified(java.io.File file)
Returns the lastModified attribute of the file. |
long |
length(java.io.File file)
Invokes File.length() on the given file . |
java.io.File[] |
listFiles(java.io.File file)
Invokes File.listFiles() on the given file . |
java.util.Properties |
loadProperties(java.io.File file)
Load Properties from a file. |
boolean |
mkdirs(java.io.File file)
Invokes File.mkdirs() on the given file . |
java.io.InputStream |
newFileInputStream(java.io.File file)
Creates a new InputStream for the given file . |
java.io.OutputStream |
newFileOutputStream(java.io.File file)
Creates a new OutputStream for the given file . |
boolean |
renameTo(java.io.File oldDir,
java.io.File newDir)
Invokes File.renameTo(File) on the given files. |
boolean |
saveProperties(java.io.File file,
java.util.Properties props,
java.lang.String comments)
Saves (write, store) the given Properties into the given File . |
void |
setExecutablePermission(java.io.File file)
Sets the executable Unix permission (+x) on a file or folder. |
void |
setReadOnly(java.io.File file)
Sets the file or directory as read-only. |
Method Detail |
---|
void deleteFileOrFolder(@NonNull java.io.File fileOrFolder)
void setExecutablePermission(@NonNull java.io.File file) throws java.io.IOException
file
- The file to set permissions on.
java.io.IOException
- If an I/O error occursvoid setReadOnly(@NonNull java.io.File file)
file
- The file or directory to set permissions on.void copyFile(@NonNull java.io.File source, @NonNull java.io.File dest) throws java.io.IOException
source
- the source file to copy.dest
- the destination file to write.
java.io.FileNotFoundException
- if the source file doesn't exist.
java.io.IOException
- if there's a problem reading or writing the file.boolean isSameFile(@NonNull java.io.File file1, @NonNull java.io.File file2) throws java.io.IOException
file1
- the source file to copyfile2
- the destination file to write
java.io.FileNotFoundException
- if the source files don't exist.
java.io.IOException
- if there's a problem reading the files.boolean exists(@NonNull java.io.File file)
File.exists()
on the given file
.
boolean isFile(@NonNull java.io.File file)
File.isFile()
on the given file
.
boolean isDirectory(@NonNull java.io.File file)
File.isDirectory()
on the given file
.
long length(@NonNull java.io.File file)
File.length()
on the given file
.
boolean delete(@NonNull java.io.File file)
File.delete()
on the given file
.
Note: for a recursive folder version, consider deleteFileOrFolder(File)
.
boolean mkdirs(@NonNull java.io.File file)
File.mkdirs()
on the given file
.
@NonNull java.io.File[] listFiles(@NonNull java.io.File file)
File.listFiles()
on the given file
.
Contrary to the Java API, this returns an empty array instead of null when the
directory does not exist.
boolean renameTo(@NonNull java.io.File oldDir, @NonNull java.io.File newDir)
File.renameTo(File)
on the given files.
@NonNull java.io.OutputStream newFileOutputStream(@NonNull java.io.File file) throws java.io.FileNotFoundException
OutputStream
for the given file
.
java.io.FileNotFoundException
@NonNull java.io.InputStream newFileInputStream(@NonNull java.io.File file) throws java.io.FileNotFoundException
InputStream
for the given file
.
java.io.FileNotFoundException
@NonNull java.util.Properties loadProperties(@NonNull java.io.File file)
Properties
from a file. Returns an empty property set on error.
file
- A non-null file to load from. File may not exist.
Properties
with the properties loaded from the file,
or an empty property set in case of error.boolean saveProperties(@NonNull java.io.File file, @NonNull java.util.Properties props, @NonNull java.lang.String comments)
Properties
into the given File
.
file
- A non-null file to write to.props
- The properties to write.comments
- A non-null description of the properly list, written in the file.
long lastModified(@NonNull java.io.File file)
file
- The non-null file of which to retrieve the lastModified attribute.
File.lastModified()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |