|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.sdklib.io.FileOp
public class FileOp
Wraps some common File operations on files and folders.
| Constructor Summary | |
|---|---|
FileOp()
|
|
| Method Summary | |
|---|---|
static java.io.File |
append(java.io.File base,
java.lang.String... segments)
Appends the given segments to the base file. |
static java.io.File |
append(java.lang.String base,
java.lang.String... segments)
Appends the given segments to the base file. |
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 source,
java.io.File destination)
Checks whether 2 binary files are the same. |
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.OutputStream |
newFileOutputStream(java.io.File file)
Creates a new FileOutputStream for the given file. |
boolean |
renameTo(java.io.File oldFile,
java.io.File newFile)
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileOp()
| Method Detail |
|---|
public static java.io.File append(java.io.File base,
java.lang.String... segments)
segments to the base file.
base - A base file, non-null.segments - Individual folder or filename segments to append to the base file.
public static java.io.File append(java.lang.String base,
java.lang.String... segments)
segments to the base file.
base - A base file path, non-empty and non-null.segments - Individual folder or filename segments to append to the base path.
public void deleteFileOrFolder(java.io.File fileOrFolder)
deleteFileOrFolder in interface IFileOp
public void setExecutablePermission(java.io.File file)
throws java.io.IOException
setExecutablePermission in interface IFileOpfile - The file to set permissions on.
java.io.IOException - If an I/O error occurspublic void setReadOnly(java.io.File file)
IFileOp
setReadOnly in interface IFileOpfile - The file or directory to set permissions on.
public void copyFile(java.io.File source,
java.io.File dest)
throws java.io.IOException
copyFile in interface IFileOpsource - 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.
public boolean isSameFile(java.io.File source,
java.io.File destination)
throws java.io.IOException
isSameFile in interface IFileOpsource - the source file to copydestination - 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.public boolean isFile(java.io.File file)
File.isFile() on the given file.
isFile in interface IFileOppublic boolean isDirectory(java.io.File file)
File.isDirectory() on the given file.
isDirectory in interface IFileOppublic boolean exists(java.io.File file)
File.exists() on the given file.
exists in interface IFileOppublic long length(java.io.File file)
File.length() on the given file.
length in interface IFileOppublic boolean delete(java.io.File file)
File.delete() on the given file.
Note: for a recursive folder version, consider deleteFileOrFolder(File).
delete in interface IFileOppublic boolean mkdirs(java.io.File file)
File.mkdirs() on the given file.
mkdirs in interface IFileOppublic java.io.File[] listFiles(java.io.File file)
File.listFiles() on the given file.
listFiles in interface IFileOp
public boolean renameTo(java.io.File oldFile,
java.io.File newFile)
File.renameTo(File) on the given files.
renameTo in interface IFileOp
public java.io.OutputStream newFileOutputStream(java.io.File file)
throws java.io.FileNotFoundException
FileOutputStream for the given file.
newFileOutputStream in interface IFileOpjava.io.FileNotFoundException
@NonNull
public java.util.Properties loadProperties(@NonNull
java.io.File file)
IFileOpProperties from a file. Returns an empty property set on error.
loadProperties in interface IFileOpfile - 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.
public boolean saveProperties(@NonNull
java.io.File file,
@NonNull
java.util.Properties props,
@NonNull
java.lang.String comments)
IFileOpProperties into the given File.
saveProperties in interface IFileOpfile - 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||