Extension of java.io.File for working with the secure file system. More...
This class is a subclass of java.io.File
for working with the BlackBerry Dynamics secure file system.
See the com.good.gd.file package documentation for an introduction to the secure file system.
This class has the same programming interface as the java.i
o.File
class with the following exceptions.
deleteOnExit
method has no effect. Note that deleteOnExit
is not generally advisable on the native platform in any case.setReadOnly
, setWritable
, setReadable
, and setExecutable
. All files in the secure store are always readable, writable, and not executable./
character.getCanonical...
methods return the same values as the corresponding getAbsolute...
methods.getTotalSpace
method returns information relating to the device storage partition that holds the secure file system. All files and directories in the secure store will be in the same storage partition.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
File (String parent, String child) | |
Construct new instance from String objects containing parent path and child path. More... | |
File (java.io.File parent, String child) | |
Construct new instance from parent Fi le and child String . More... | |
File (URI uri) | |
Construct new instance from fi le: URI. More... | |
File (String pathname) | |
Construct new instance from String . More... | |
boolean | canExecute () |
Check execute permission; always returns false . More... | |
boolean | canRead () |
Check read permission. More... | |
boolean | canWrite () |
Check write permission. More... | |
boolean | createNewFile () throws IOException |
Create an empty file in the secure file system. More... | |
boolean | delete () |
Delete a file or directory from the secure store. More... | |
void | deleteOnExit () |
Mark a file or directory to be deleted on exit (not supported). More... | |
int | compareTo (java.io.File pathname) |
Lexicographic comparison of paths. More... | |
boolean | equals (Object obj) |
Lexicographic comparison of path and other object. More... | |
boolean | exists () |
Test for the existence of a file or directory in the secure store. More... | |
java.io.File | getAbsoluteFile () |
Get the absolute form of a path in the secure file system. More... | |
String | getAbsolutePath () |
Get a String containing the absolute form of a path in the secure file system. More... | |
java.io.File | getCanonicalFile () throws IOException |
Get the canonical form of a path in the secure file system (not supported). More... | |
String | getCanonicalPath () throws IOException |
Get a String containing the canonical form of a path in the secure file system (not supported). More... | |
String | getName () |
Get the name part of a path in the secure file system. More... | |
String | getParent () |
Get the parent part of a path in the secure file system. More... | |
java.io.File | getParentFile () |
Get a new instance containing the parent part of this instance's path in the secure file system. More... | |
String | getPath () |
Convert the path to a String . More... | |
long | getFreeSpace () |
Check how much unallocated space there is on the storage partition that contains the secure store. More... | |
long | getTotalSpace () |
Check the size of the storage partition that contains the secure store. More... | |
long | getUsableSpace () |
Check how much space is available to use on the storage partition that contains the secure store. More... | |
int | hashCode () |
Compute a hash code for a path in the secure store. More... | |
boolean | isAbsolute () |
Test whether a path in the secure store is absolute. More... | |
boolean | isDirectory () |
Check for the existence of a directory in the secure store. More... | |
boolean | isFile () |
Check for the existence of a plain file in the secure store. More... | |
boolean | isHidden () |
Check if a file or directory in the secure store is hidden. More... | |
long | lastModified () |
Get the last modified time of a file or directory in the secure store. More... | |
long | length () |
Get the size of a file in the secure store, as if decrypted. More... | |
String[] | list () |
Contents of a secure file system directory as a String array. More... | |
String[] | list (java.io.FilenameFilter filter) |
Filtered list of the contents of a secure file system directory as a String array. More... | |
java.io.File[] | listFiles () |
Contents of a secure file system directory as a Fi le array. More... | |
java.io.File[] | listFiles (java.io.FileFilter filter) |
Filtered list of the contents of a secure file system directory as a Fi le array. More... | |
java.io.File[] | listFiles (java.io.FilenameFilter filter) |
Filtered list of the contents of a secure file system directory as a Fi le array. More... | |
boolean | mkdir () |
Create a sub-directory in the secure file system. More... | |
boolean | mkdirs () |
Create all directories on a path, in the secure file system. More... | |
boolean | renameTo (java.io.File dest) |
Move or rename a file or directory within the secure file system. More... | |
boolean | setExecutable (boolean executable) |
Set execute permission for owner (not supported). More... | |
boolean | setExecutable (boolean executable, boolean ownerOnly) |
Set execute permission for owner or all (not supported). More... | |
boolean | setReadable (boolean readable) |
Set read permission for owner (not supported). More... | |
boolean | setReadable (boolean readable, boolean ownerOnly) |
Set read permission for owner or all (not supported). More... | |
boolean | setWritable (boolean writable) |
Set write permission for owner (not supported). More... | |
boolean | setWritable (boolean writable, boolean ownerOnly) |
Set write permission for owner or all (not supported). More... | |
boolean | setLastModified (long time) |
Set the last modified time of a file or directory in the secure file system. More... | |
boolean | setReadOnly () |
Remove write permission (not supported). More... | |
String | toString () |
Convert the path to a String . More... | |
URI | toURI () |
Convert the path to a URI . More... | |
Static Public Member Functions | |
static java.io.File | createTempFile (String prefix, String suffix) throws IOException |
Create a temporary file in the default directory for temporary files in the secure store. More... | |
static java.io.File | createTempFile (String prefix, String suffix, java.io.File directory) throws IOException |
Create a temporary file in the specified directory in the secure store. More... | |
static java.io.File[] | listRoots () |
List the available roots in the secure file system; always returns ["/"] . More... | |
File | ( | String | parent, |
String | child | ||
) |
Call this constructor to create a new instance from a parent path and a child path.
parent | String containing the parent path, within the secure file system. |
child | String containing the child path, which will be appended to the parent path. |
com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
File | ( | java.io.File | parent, |
String | child | ||
) |
Call this constructor to create a new instance from a parent Fi
le
and a child path.
parent | Fi le containing the parent path, within the secure file system. |
child | String containing the child path, which will be appended to the parent path. |
com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
File | ( | URI | uri | ) |
Call this constructor to create a new instance from a Uniform Resource Identifier (URI) with the fi
le:
scheme.
uri | URI containing the path, within the secure file system. |
com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
File | ( | String | pathname | ) |
Call this constructor to create a new instance from a String
.
pathname | String containing the path, within the secure file system. |
com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
boolean canExecute | ( | ) |
Call this method to test whether the file at the instance's path is executable. This method is provided for completeness; files in the secure store are never executable.
false
always. boolean canRead | ( | ) |
Call this method to test whether the file or directory at the instance's path is readable. Files and directories in the secure store are always readable, so this method only checks for existence.
true
if the instance's path corresponds to a file or directory that exists in the secure store. false
otherwise. boolean canWrite | ( | ) |
Call this method to test whether the file or directory at the instance's path is writable. Files and directories in the secure store are always writable, so this method only checks for existence.
true
if the instance's path corresponds to a file or directory that exists in the secure store. false
otherwise. boolean createNewFile | ( | ) | throws IOException |
Call this method to create a new, empty file at the instance's path. If a file already exists at the path in the secure file system, calling this method has no effect.
true
if the file did not exist and was created. false
otherwise.IOException |
|
static |
Calling this method is the same as calling the three-parameter method, below, with a null directory parameter.
IOException |
|
static |
Call this method to create a temporary file in the specified directory in the secure store. A file name will be generated that begins with the specified prefix, ends with the specified suffix, and is unique in the directory.
prefix | String containing the file name prefix. Must be at least three characters. |
suffix | String containing the file name suffix. Defaults to ".tmp" if a null pointer is passed. |
directory | Fi le containing the path of the directory in which the temporary file is to be created, within the secure store. Defaults to a system designated path if a null pointer is passed. |
Fi
le
instance for the created temporary file.IOException |
boolean delete | ( | ) |
Call this method to delete the file or directory at the instance's path.
true
if the file or directory existed and was deleted. false
otherwise. void deleteOnExit | ( | ) |
Call this method to request that the instance's file is to be deleted when the JVM terminates. The request will be ignored. Calling this method has no effect.
This method is provided for completeness only; the secure store doesn't support delete-on-exit.
int compareTo | ( | java.io.File | pathname | ) |
Call this method to compare the path of one instance with the path of another, lexicographically.
boolean equals | ( | Object | obj | ) |
Call this method to compare the instance's path with another object.
obj | Object to which comparison is being made. |
true
if the instance's path matches the object. false
otherwise. boolean exists | ( | ) |
This method checks if the instance's path corresponds to an existing file or directory in the secure store.
true
if the instance's path exists in the secure store. false
otherwise. java.io.File getAbsoluteFile | ( | ) |
This method returns a new instance whose path is the absolute form of this instance's path.
Note that there is no current working directory in the secure file system. Paths that are not absolute will be interpreted relative to the root directory of the secure store.
File
containing the absolute path. String getAbsolutePath | ( | ) |
This method returns the absolute form of the instance's path in a String
.
Note that there is no current working directory in the secure file system. Paths that are not absolute will be interpreted relative to the root directory of the secure store.
String
containing the absolute path. java.io.File getCanonicalFile | ( | ) | throws IOException |
This class doesn't support resolution of paths to canonical form.
getAbsoluteFile
. String getCanonicalPath | ( | ) | throws IOException |
This class doesn't support resolution of paths to canonical form.
getAbsoluteFile
. String getName | ( | ) |
String
containing the name part of the instance's path. String getParent | ( | ) |
String
containing the parent part of the instance's path, or a null pointer if there is no parent part. java.io.File getParentFile | ( | ) |
File
containing the parent part of the instance's path, or a null pointer if there is no parent part. String getPath | ( | ) |
String
containing the instance's path in the secure store. long getFreeSpace | ( | ) |
This method returns the amount of unallocated space in the storage partition that contains the secure store, as a number of bytes.
long
representation of the number of unallocated bytes. long getTotalSpace | ( | ) |
This method returns the size of the partition that contains the secure store, in bytes.
long
representation of the size of the partition in bytes. long getUsableSpace | ( | ) |
This method returns the amount of useable space in the partition that contains the secure store, as a number of bytes.
long
representation of the number of useable bytes. int hashCode | ( | ) |
This method computes a hash code for the instance's path.
int
representation of the computed hash code. boolean isAbsolute | ( | ) |
true
if the instance's path is in absolute form. false
otherwise. boolean isDirectory | ( | ) |
This method checks if the instance's path corresponds to an existing directory in the secure store.
true
if the instance's path exists in the secure store, and is a directory. false
otherwise. boolean isFile | ( | ) |
Call this method to check if the instance's path corresponds to a plain file, not a directory, in the secure store.
true
if the instance's path exists in the secure store, and is a plain file. false
otherwise. boolean isHidden | ( | ) |
true
if the instance's path is a hidden file or directory. false
otherwise. long lastModified | ( | ) |
long
representation of the modified time of the instance's file or directory. long length | ( | ) |
Call this method to obtain the length of the instance's file in the secure store. Note that the value is based on file as if it had been decrypted.
long
representation of the length of the file in bytes. String [] list | ( | ) |
This method returns a list of the decrypted file and directory names that are in the instance's directory, in a String
array.
String
array of the names of the files and directories. String [] list | ( | java.io.FilenameFilter | filter | ) |
This method returns a list of the decrypted file and directory names that are in the instance's directory, and which satisfy the specified filter criteria, in a String
array.
filter | java.io.FilenameFilter representation of the filter criteria. |
String
array of the names of the files and directories. java.io.File [] listFiles | ( | ) |
This method returns a list of the decrypted file and directory names that are in the instance's directory, in a Fi
le
array. The array elements returned are always instances of com.good.gd.file.File
, and can be safely cast to that type.
Fi
le
array of the names of the files and directories. java.io.File [] listFiles | ( | java.io.FileFilter | filter | ) |
This method returns a list of the decrypted file and directory names that are in the instance's directory, and which satisfy the specified filter criteria, in a Fi
le
array. The array elements returned are always instances of com.good.gd.file.File
, and can be safely cast to that type.
filter | java.io.FileFilter representation of the filter criteria. |
Fi
le
array of the names of the files and directories. java.io.File [] listFiles | ( | java.io.FilenameFilter | filter | ) |
This method returns a list of the decrypted file and directory names that are in the instance's directory, and which satisfy the specified filter criteria, in a Fi
le
array. The array elements returned are always instances of com.good.gd.file.File
, and can be safely cast to that type.
filter | java.io.FilenameFilter representation of the filter criteria. |
Fi
le
array of the names of the files and directories.
|
static |
This method returns a list of the available roots in the secure file system. There is only one root in the secure file system, so this method always returns an array with a single element, "/"
.
Fi
le
array of available roots in the secure file system. boolean mkdir | ( | ) |
Call this method to create a directory at the instance's path, within the secure file system. The parent directory must already exist.
If there is already a file or directory at the instance's path, then this method will fail.
true
if the directory was created. false
otherwise. boolean mkdirs | ( | ) |
Call this method to create a directory at the instance's path, within the secure file system. Any missing directories on the instance's path will also be created.
If there is already a file or directory at the instance's path, then this method will fail.
true
if the directory was created. false
otherwise. boolean renameTo | ( | java.io.File | dest | ) |
dest | Fi le representation of the destination path, within the secure file system. |
true
if the instance's file or directory was moved or renamed to the specified destination. false
otherwise. boolean setExecutable | ( | boolean | executable | ) |
Call this method to set or clear owner execute permission on the file at the instance's path. This method is provided for completeness; files in the secure store are never executable.
true
if the path exists and the specified permission is false
. false
otherwise. boolean setExecutable | ( | boolean | executable, |
boolean | ownerOnly | ||
) |
Call this method to set or clear execute permission on the file at the instance's path. This method is provided for completeness; files in the secure store are never executable.
true
if the path exists and the specified permission is false
. false
otherwise. boolean setReadable | ( | boolean | readable | ) |
Call this method to set or clear owner read permission on the file at the instance's path. This method is provided for completeness; files in the secure store are always readable.
true
if the path exists and the specified permission is true
. false
otherwise. boolean setReadable | ( | boolean | readable, |
boolean | ownerOnly | ||
) |
Call this method to set or clear read permission on the file at the instance's path. This method is provided for completeness; files in the secure store are always readable.
true
if the path exists and the specified permission is true
. false
otherwise. boolean setWritable | ( | boolean | writable | ) |
Call this method to set or clear owner write permission on the file at the instance's path. This method is provided for completeness; files in the secure store are always writable.
true
if the path exists and the specified permission is true
. false
otherwise. boolean setWritable | ( | boolean | writable, |
boolean | ownerOnly | ||
) |
Call this method to set or clear write permission on the file at the instance's path. This method is provided for completeness; files in the secure store are always writable.
true
if the path exists and the specified permission is true
. false
otherwise. boolean setLastModified | ( | long | time | ) |
Call this method to set the last modified time of the instance's file or directory in the secure file system.
time | long representation of the time to set. |
true
if the last modified time was set. false
otherwise. boolean setReadOnly | ( | ) |
Call this method to clear write permission on the file at the instance's path. This method is provided for completeness; files in the secure store are always writable.
false
always. String toString | ( | ) |
This method returns the same value as the getPath
method.
String
containing the instance's path in the secure store. URI toURI | ( | ) |
The method returns a Uniform Resource Identifier (URI) for the path in the secure file system. The URI will have the fi
le:
scheme.
Note that the URI isn't transferable and can only be used within the BlackBerry Dynamics programming interface.
URI
containing the path in the secure store.