|
![]() |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.siemens.mp.io.File
The File class holds basic methods for accessing files on the phone's file system.
The first time you run any class method, a storage subfolder under the application folder is created. In general, ".." is forbidden in path specifications. Depending on the phone model, different further restrictions apply to the path specification:
SL45i, 6688i | On these phones only relative path specifications are allowed. 'Relative' means relative to the application's path. This means that a MIDlet may only access its storage folder and its subfolders. There is no way to create a subfolder, so all files are placed in the storage folder directly. |
C55, C56, CT56, 2128 | In addition to the relative path specifications, these phones allow access to the following folders: Ringing Tone, Bitmap and Animation. An absolute path specification always has to start with "a:\", that means the path specifications to the folders above are "a:\Ringing Tone", "a:\Bitmap" and "a:\Animation". For security reasons the user has to explicitly confirm the access to one of those folders. This happens only once per folder and per session. |
S55, S56, S57, S57 SL55, M55 | On these phones, path specifications are not restricted to any specific folder; "a:\" specifies the file system's root and an absolute path specification always has to start with this prefix. As with the phone models above, the user has to explicitly confirm the access to any folder. The phone keeps a history of the last 10 confirmed folders. Those 10 folders need only to be confirmed once per session, whereas accessing more than 10 folders may result in another confirmation request for a formerly already confirmed folder. |
Field Summary | |
static int |
INSIDE_STORAGE_PATH
|
static int |
OUTSIDE_STORAGE_PATH
|
static String |
STORAGE_DRIVE
|
Constructor Summary | |
File()
|
Method Summary | |
static String |
buildPath(String fileName)
|
static int |
checkFileName(String fileName)
checkFileName |
int |
close(int fileDescriptor)
Closes the file. |
static int |
copy(String source,
String dest)
Creates a file copy. |
static int |
debugWrite(String fileName,
String infoString)
Writes a given string at the end of the file specified by the file name. |
static int |
delete(String fileName)
Deletes the file specified by its file name from the storage directory. |
static int |
exists(String fileName)
Checks if the file specified by the file name exists |
static boolean |
isDirectory(String pathName)
Checks if the given path specifies a directory |
int |
length(int fileDescriptor)
Returns the file length, in bytes. |
static String[] |
list(String pathName)
Lists the content of a directory |
int |
open(String fileName)
Opens the file specified by the file name and prepares it for reading or writing. |
int |
read(int fileDescriptor,
byte[] buf,
int offset,
int numBytes)
Reads a maximum of numBytes bytes into a buffer from a file. |
static int |
rename(String source,
String dest)
Renames a file from source filename to destination filename. |
int |
seek(int fileDescriptor,
int seekpos)
Moves the file pointer to the specified location. |
static int |
spaceAvailable()
Returns the free disk space (in bytes), available on the phone's file system. |
static void |
truncate(int fileDescriptor,
int size)
Set the size of a file |
int |
write(int fileDescriptor,
byte[] buf,
int offset,
int numBytes)
Writes numBytes bytes from buffer to a file. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OUTSIDE_STORAGE_PATH
public static final int INSIDE_STORAGE_PATH
public static final String STORAGE_DRIVE
Constructor Detail |
public File()
Method Detail |
public static int checkFileName(String fileName)
fileName
- Name of file to be checked
IllegalArgumentException
- if specified file name violates security policiespublic static int debugWrite(String fileName, String infoString)
fileName
- the name of the file to write toinfoString
- the string that will be written to the file
IOException
- if some other kind of I/O error occurs.
public int open(String fileName) throws IOException
fileName
- the name of the file to be opened
IllegalArgumentException
- if the path is invalid
IOException
- if some other kind of I/O error occurs.
public static int exists(String fileName)
fileName
- the name of the file
IllegalArgumentException
- if the path is invalidcopy
,
rename
,
delete
public int seek(int fileDescriptor, int seekpos) throws IOException
fileDescriptor
- file descriptorseekpos
- position to set the file pointer to i.e.
the number of bytes from the beginning of the file
IOException
- if some kind of I/O error occurs.open
,
read
,
write
public int length(int fileDescriptor) throws IOException
fileDescriptor
- file descriptor
IOException
open
public int close(int fileDescriptor) throws IOException
fileDescriptor
- the file descriptor
IOException
- if some kind of I/O error occurs.open
public int write(int fileDescriptor, byte[] buf, int offset, int numBytes) throws IOException
fileDescriptor
- the file descriptorbuf
- the bytearray with data to be writtenoffset
- offset of the data to be written within the bytearraynumBytes
- number of bytes to be written
IOException
- if some kind of I/O error occurs.open
,
read
,
seek
public int read(int fileDescriptor, byte[] buf, int offset, int numBytes) throws IOException
fileDescriptor
- the file descriptorbuf
- the buffer for the data to be readoffset
- offset within the buffer for data to be readnumBytes
- number of bytes to read
IOException
- if some kind of I/O error occurs.open
,
write
,
seek
public static int delete(String fileName) throws IOException
fileName
- name of the file to be deleted
IllegalArgumentException
- if the path is invalid
IOException
- if some other kind of I/O error occurs.exists
,
copy
,
rename
public static int spaceAvailable() throws IOException
IOException
- if some kind of I/O error occurs.
public static int rename(String source, String dest) throws IOException
source
- source name of the filedest
- destination name of the file
IllegalArgumentException
- if the path is invalid
IOException
- if some other kind of I/O error occurs.exists
,
copy
,
delete
public static int copy(String source, String dest) throws IOException
source
- name of the source filedest
- name of the destination file (the file copy)
IllegalArgumentException
- if the path is invalid
IOException
- if some other kind of I/O error occurs.exists
,
rename
,
delete
public static boolean isDirectory(String pathName) throws IOException
pathName
- the name of the path to be checked
IllegalArgumentException
- if the path is invalid
IOException
- if some kind of I/O error occurs.
open
,
copy
,
rename
,
delete
public static String[] list(String pathName) throws IOException
pathName
- path to directory to be listed
IllegalArgumentException
- if the path is invalid
IOException
- if some kind of I/O error occurs.
open
,
copy
,
rename
,
delete
public static String buildPath(String fileName)
public static void truncate(int fileDescriptor, int size) throws IOException
fileDescriptor
- the file descriptorsize
- size to truncate the file stream to.
IOException
- if some kind of I/O error occurs.
|
![]() |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Generated on 2003-10-17 | For further information and updates, please visit Siemens mobile Developer Portal |