|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.repository.io.impl.FileOpImpl
public class FileOpImpl
Wraps some common File operations on files and folders.
FileOpUtils.create()
| Field Summary |
|---|
| Fields inherited from interface com.android.repository.io.FileOp |
|---|
EMPTY_FILE_ARRAY |
| Constructor Summary | |
|---|---|
FileOpImpl()
|
|
| Method Summary | |
|---|---|
boolean |
canExecute(java.io.File file)
|
boolean |
canWrite(java.io.File file)
Invokes File.canWrite() on the given file. |
void |
copyFile(java.io.File source,
java.io.File dest)
Copies a binary file. |
boolean |
createNewFile(java.io.File file)
Creates a new 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. |
void |
deleteOnExit(java.io.File file)
|
java.io.File |
ensureRealFile(java.io.File in)
If in is an in-memory file, write it out as a proper file and return it. |
boolean |
equals(java.lang.Object o)
|
boolean |
exists(java.io.File file)
Invokes File.exists() on the given file. |
int |
hashCode()
|
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. |
boolean |
isWindows()
Returns true if we're on windows, false otherwise. |
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.lang.String[] |
list(java.io.File folder,
java.io.FilenameFilter filenameFilter)
|
java.io.File[] |
listFiles(java.io.File file)
Invokes File.listFiles() on the given file. |
java.io.File[] |
listFiles(java.io.File folder,
java.io.FilenameFilter filenameFilter)
|
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 oldFile,
java.io.File newFile)
Invokes File.renameTo(File) on the given files. |
void |
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. |
java.lang.String |
toString(java.io.File f,
java.nio.charset.Charset c)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileOpImpl()
| Method Detail |
|---|
public void deleteFileOrFolder(@NonNull
java.io.File fileOrFolder)
FileOp
deleteFileOrFolder in interface FileOp
public void setExecutablePermission(@NonNull
java.io.File file)
throws java.io.IOException
FileOp
setExecutablePermission in interface FileOpfile - The file to set permissions on.
java.io.IOException - If an I/O error occurs
public void setReadOnly(@NonNull
java.io.File file)
FileOp
setReadOnly in interface FileOpfile - The file or directory to set permissions on.
public void copyFile(@NonNull
java.io.File source,
@NonNull
java.io.File dest)
throws java.io.IOException
FileOp
copyFile in interface FileOpsource - 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(@NonNull
java.io.File file1,
@NonNull
java.io.File file2)
throws java.io.IOException
FileOp
isSameFile in interface FileOpfile1 - 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.
public boolean isFile(@NonNull
java.io.File file)
FileOpFile.isFile() on the given file.
isFile in interface FileOp
public boolean isDirectory(@NonNull
java.io.File file)
FileOpFile.isDirectory() on the given file.
isDirectory in interface FileOp
public boolean exists(@NonNull
java.io.File file)
FileOpFile.exists() on the given file.
exists in interface FileOp
public boolean canWrite(@NonNull
java.io.File file)
FileOpFile.canWrite() on the given file.
canWrite in interface FileOp
public long length(@NonNull
java.io.File file)
FileOpFile.length() on the given file.
length in interface FileOp
public boolean delete(@NonNull
java.io.File file)
FileOpFile.delete() on the given file.
Note: for a recursive folder version, consider FileOp.deleteFileOrFolder(File).
delete in interface FileOp
public boolean mkdirs(@NonNull
java.io.File file)
FileOpFile.mkdirs() on the given file.
mkdirs in interface FileOp
@NonNull
public java.io.File[] listFiles(@NonNull
java.io.File file)
FileOpFile.listFiles() on the given file.
Contrary to the Java API, this returns an empty array instead of null when the
directory does not exist.
listFiles in interface FileOp
public boolean renameTo(@NonNull
java.io.File oldFile,
@NonNull
java.io.File newFile)
FileOpFile.renameTo(File) on the given files.
renameTo in interface FileOp
@NonNull
public java.io.OutputStream newFileOutputStream(@NonNull
java.io.File file)
throws java.io.FileNotFoundException
FileOpOutputStream for the given file.
newFileOutputStream in interface FileOpjava.io.FileNotFoundException
@NonNull
public java.io.InputStream newFileInputStream(@NonNull
java.io.File file)
throws java.io.FileNotFoundException
FileOpInputStream for the given file.
newFileInputStream in interface FileOpjava.io.FileNotFoundException
@NonNull
public java.util.Properties loadProperties(@NonNull
java.io.File file)
FileOpProperties from a file. Returns an empty property set on error.
loadProperties in interface FileOpfile - 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 void saveProperties(@NonNull
java.io.File file,
@NonNull
java.util.Properties props,
@NonNull
java.lang.String comments)
throws java.io.IOException
FileOpProperties into the given File.
saveProperties in interface FileOpfile - 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.
java.io.IOException - if the write operation failed.
public long lastModified(@NonNull
java.io.File file)
FileOp
lastModified in interface FileOpfile - The non-null file of which to retrieve the lastModified attribute.
File.lastModified()
public boolean createNewFile(@NonNull
java.io.File file)
throws java.io.IOException
FileOpFile.createNewFile().
createNewFile in interface FileOpjava.io.IOExceptionpublic boolean isWindows()
FileOptrue if we're on windows, false otherwise.
isWindows in interface FileOp
public boolean canExecute(@NonNull
java.io.File file)
canExecute in interface FileOpFile.canExecute()
public java.io.File ensureRealFile(@NonNull
java.io.File in)
FileOpin is an in-memory file, write it out as a proper file and return it.
Otherwise just return in.
ensureRealFile in interface FileOp
@NonNull
public java.lang.String toString(@NonNull
java.io.File f,
@NonNull
java.nio.charset.Charset c)
throws java.io.IOException
toString in interface FileOpjava.io.IOExceptionFiles.toString(File, Charset)
@Nullable
public java.lang.String[] list(@NonNull
java.io.File folder,
@Nullable
java.io.FilenameFilter filenameFilter)
list in interface FileOpFile.list(FilenameFilter)
@Nullable
public java.io.File[] listFiles(@NonNull
java.io.File folder,
@Nullable
java.io.FilenameFilter filenameFilter)
listFiles in interface FileOpFile.listFiles(FilenameFilter)public void deleteOnExit(java.io.File file)
deleteOnExit in interface FileOpFile.deleteOnExit()public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||