|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.platform.FileAdapter
public class FileAdapter
This class is a proxy to javax.microedition.io.file.FileConnection to provide a common access to a file resource on all mobile platforms. A portable code must use this class only to access files, and must take care of closing the FileAdapter when not used anymore.
Example: void fileAccessExample(String path) { FileAdapter fa = new FileAdapter(path); // opens the FileConnection InputStream is = fa.openInputStream(); // opens the InputStream while( (char c = is.read()) != -1) { // read till the end of the file System.out.print(c); } is.close(); // closes the InputStream fa.close(); // closes the FileConnection
Constructor Summary | |
---|---|
FileAdapter(java.lang.String path)
Creates a FileAdapter instance, opening the underlying FileConnection in read/write mode. |
|
FileAdapter(java.lang.String path,
boolean readOnly)
Creates a FileAdapter instance, opening the underlying FileConnection. |
Method Summary | |
---|---|
void |
close()
Close this FileAdapter |
void |
create()
Create a file with the name of this FileAdapter. |
void |
delete()
Delete the file with the name of this FileAdapter. |
boolean |
exists()
Check if the file with the name of this FileAdapter exists. |
java.lang.String |
getName()
Returns the name of a file or directory excluding the URL schema and all paths. |
long |
getSize()
Check if the file with the name of this FileAdapter exists. |
boolean |
isDirectory()
Returns if this FileAdapter represents a directory on the underlying file system. |
boolean |
isSetLastModifiedSupported()
Returns true if the underlying platform supports the setLastModified method. |
long |
lastModified()
Returns the timestamp of the last modification to the file |
java.util.Enumeration |
list(boolean includeSubdirs)
Gets a list of all visible files and directories contained in a directory. |
void |
mkdir()
Creates a directory corresponding to the directory string provided in the constructor. |
java.io.InputStream |
openInputStream()
Open and return an input stream for this FileHandler. |
java.io.OutputStream |
openOutputStream()
Open and return an output stream for this FileHandler. |
java.io.OutputStream |
openOutputStream(boolean append)
Open and return an output stream for this FileHandler. |
void |
rename(java.lang.String newName)
Renames this File to the name represented by the File dest. |
void |
setLastModified(long date)
Sets the last modification time for this file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileAdapter(java.lang.String path) throws java.io.IOException
java.io.IOException
public FileAdapter(java.lang.String path, boolean readOnly) throws java.io.IOException
path
- the file pathreadOnly
- true if file shall be opened in read only mode
java.io.IOException
Method Detail |
---|
public java.io.InputStream openInputStream() throws java.io.IOException
java.io.IOException
public java.io.OutputStream openOutputStream() throws java.io.IOException
java.io.IOException
public java.io.OutputStream openOutputStream(boolean append) throws java.io.IOException
append
- if TRUE, open the file for appending, otherwise the
file is truncated to the beginning.
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public void create() throws java.io.IOException
java.io.IOException
public void delete() throws java.io.IOException
java.io.IOException
public void rename(java.lang.String newName) throws java.io.IOException
newName
- - the File containing the new name.
java.io.IOException
public boolean exists() throws java.io.IOException
java.io.IOException
public long getSize() throws java.io.IOException
java.io.IOException
public boolean isDirectory() throws java.io.IOException
java.io.IOException
public java.util.Enumeration list(boolean includeSubdirs) throws java.io.IOException
java.io.IOException
public void mkdir() throws java.io.IOException
java.io.IOException
- if the directory cannot be created.public java.lang.String getName()
public long lastModified()
public boolean isSetLastModifiedSupported()
public void setLastModified(long date) throws java.io.IOException
date
- the modification time expressed as UTC
java.io.IOException
- if the operation cannot be performed (in this
implementation this is always the case)isSetLastModifiedSupported.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |