IM Profile

com.siemens.icm.io
Class File

java.lang.Object
  extended bycom.siemens.icm.io.File

Deprecated. Use javax.microedition.io.FileConnection instead

public class File
extends Object

The File class holds basic methods for accessing files on the MMC file system.

The first time you run this class method, a storage subfolder in the application folder is created. In the current API version, there is no way to create subfolders, so all files are placed in the storage folder if the given path is relative to the application folder. Futhermore, ".." and "." is forbidden in relative path which means that all path must be relative to the application folder (which accesses the storage subfolder) or absolute to the file system root (which accesses the file as given in the path).
Please consider that currently a maximum number of 10 files can be opened at the same time. This concerns the open() as well as the debugWrite() function.
Please consider also that additional to all ASCII characters below 32 the following characters are not allowed in file names:
: / \ * ? | < > "

The copy protection for JAR files avoid external reading, copying, moving or renaming of this kind of files.


Field Summary
static int INSIDE_STORAGE_PATH
          Deprecated.  
static int OUTSIDE_STORAGE_PATH
          Deprecated.  
 
Constructor Summary
File()
          Deprecated.  
 
Method Summary
 void close()
          Deprecated. Closes the file.
static void copy(String source, String dest)
          Deprecated. Performs a file copy.
static void debugWrite(String fileName, String infoString)
          Deprecated. Writes a given string at the end of the file specified by the file name.
static void delete(String fileName)
          Deprecated. Deletes the file specified by its file name from the storage directory.
static boolean exists(String fileName)
          Deprecated. Checks if the file specified by the file name does exist.
static char getAttributes(String fileName)
          Deprecated. Returns the attribute byte of a file or folder.
static boolean getCanRead(String fileName)
          Deprecated. Returns the RO bit of the attribute byte of a file or folder.
static boolean getCanWrite(String fileName)
          Deprecated. Returns the complement of the RO bit of the attribute byte of a file or folder.
static long getDirectorySize(String directoryName)
          Deprecated. Returns the size of a folder.
static boolean getIsHidden(String fileName)
          Deprecated. Returns the Hidden bit of the attribute byte of a file or folder.
static long getLastModified(String fileName)
          Deprecated. Returns the time in seconds since last modification of the file or directory.
static long getTotalSize(String fileName)
          Deprecated. Returns the total size of a drive.
static boolean isDirectory(String pathName)
          Deprecated. Checks if the given path specifies a directory.
 boolean isOpen()
          Deprecated. Return the open state of the file corresponding to the class instance.
 int length()
          Deprecated. Returns the file length, in bytes.
static String[] list(String pathName)
          Deprecated. Lists the content of a directory.
static String[] list(String pathName, boolean includeHidden)
          Deprecated. Lists the content of a directory.
static boolean mkdir(String dirName)
          Deprecated. Creates a directory.
 void open(String fileName)
          Deprecated. Opens the file specified by the file name and prepares it for reading and writing.
 int read(byte[] buf, int offset, int numBytes)
          Deprecated. Reads a maximum of numBytes bytes into a buffer from a file.
static void rename(String source, String dest)
          Deprecated. Renames a file from source filename to destination filename.
 int seek(int seekpos)
          Deprecated. Moves the file pointer to the specified location.
static void setHidden(String fileName, boolean hidden)
          Deprecated. Sets/resets the Hidden bit of the attribute byte of a file or folder.
static void setReadable(String fileName, boolean readable)
          Deprecated. Sets/resets the RO bit of the attribute byte of a file or folder.
static void setWriteable(String fileName, boolean readable)
          Deprecated. Resets/sets the RO bit of the attribute byte of a file or folder.
static int spaceAvailable()
          Deprecated. Returns the free disk space (in bytes), available on the MMC file system.
 void truncate(int byteOffset)
          Deprecated. Truncates the file at offset.
 void truncateFile(int byteOffset)
          Deprecated. Truncates the file at offset.
 int write(byte[] buf, int offset, int numBytes)
          Deprecated. 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

OUTSIDE_STORAGE_PATH

public static final int OUTSIDE_STORAGE_PATH
Deprecated. 
See Also:
Constant Field Values

INSIDE_STORAGE_PATH

public static final int INSIDE_STORAGE_PATH
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

File

public File()
Deprecated. 
Method Detail

debugWrite

public static void debugWrite(String fileName,
                              String infoString)
                       throws IOException
Deprecated. 
Writes a given string at the end of the file specified by the file name. It is useful for debug logging, because it requires no file opening and closing. Please consider that currently a maximum number of 10 files can be opened at the same time. This concerns the open() as well as the debugWrite() function.

Parameters:
fileName - the name of the file to write to
infoString - the string that will be written to the file
Throws:
IOException - if some kind of I/O error occurs

open

public void open(String fileName)
          throws IOException
Deprecated. 
Opens the file specified by the file name and prepares it for reading and writing. On success the file is opened in binary (untranslated) mode. If the specified file does not exist, it will be created.
Please consider that currently a maximum number of 10 files can be opened at the same time. This concerns the open() as well as the debugWrite() function.
Regard the limitation of 200 files and subdirectories per directory when creating new files. Having more files in a directory may result in an exception when calling list().

Parameters:
fileName - the name of the file to be opened
Throws:
IllegalArgumentException - if the path is invalid
IOException - if the file is already open or some other kind of I/O error occurs

exists

public static boolean exists(String fileName)
                      throws IOException
Deprecated. 
Checks if the file specified by the file name does exist.

Parameters:
fileName - the name of the file
Returns:
true if file exists, false if it does not exist
Throws:
IllegalArgumentException - if the given path is invalid
IOException - if some internal kind of I/O error occurs
See Also:
copy, rename, delete

seek

public int seek(int seekpos)
         throws IOException
Deprecated. 
Moves the file pointer to the specified location. The file pointer is a starting position for the next read or write operation. The file must be opened before this method call. If the specified location is greater than the current file size the file pointer is moved to the end of the file.

Parameters:
seekpos - position to set the file pointer to i.e. the number of bytes from the beginning of the file
Returns:
the offset, in bytes, of the new position from the beginning of the file
Throws:
IOException - if the file isn't open or some other kind of I/O error occurs
See Also:
open, read, write

length

public int length()
           throws IOException
Deprecated. 
Returns the file length, in bytes. The file must be opened before this method call.

Returns:
file length
Throws:
IOException - if the file isn't open or some other kind of I/O error occurs
See Also:
open

close

public void close()
           throws IOException
Deprecated. 
Closes the file. After this method call, the specified file descriptor becomes invalid.

Throws:
IOException - if the file isn't open or some other kind of I/O error occurs
See Also:
open

write

public int write(byte[] buf,
                 int offset,
                 int numBytes)
          throws IOException
Deprecated. 
Writes numBytes bytes from buffer to a file. The file must be opened before this method call. The write operation begins at the current position of the file pointer. After the write operation, the file pointer is increased by the number of bytes actually written.

Parameters:
buf - the bytearray with data to be written
offset - offset of the data to be written within the bytearray
numBytes - number of bytes to be written
Returns:
number of bytes written
Throws:
IOException - if the file isn't open or some other kind of I/O error occurs
See Also:
open, read, seek

read

public int read(byte[] buf,
                int offset,
                int numBytes)
         throws IOException
Deprecated. 
Reads a maximum of numBytes bytes into a buffer from a file. The file must be opened before this method call. The read operation begins at the current position of the file pointer. After the read operation, the file pointer points to the next unread character.

Parameters:
buf - the buffer for the data to be read
offset - offset within the buffer for data to be read
numBytes - number of bytes to read
Returns:
number of bytes actually read, which may be less than numBytes if there are fewer than numBytes bytes left in the file
Throws:
IOException - if the file isn't open or some other kind of I/O error occurs
See Also:
open, write, seek

delete

public static void delete(String fileName)
                   throws IOException
Deprecated. 
Deletes the file specified by its file name from the storage directory. Use this method with care, because the deleted file cannot be restored.

Parameters:
fileName - name of the file to be deleted
Throws:
IllegalArgumentException - if the path is invalid
IOException - if the file doesn't exist or some other kind of I/O error occurs
See Also:
exists, copy, rename

mkdir

public static boolean mkdir(String dirName)
                     throws IOException
Deprecated. 
Creates a directory.

Parameters:
dirName - name of the directory to be created
Throws:
IOException - if an I/O error occurs

getAttributes

public static char getAttributes(String fileName)
                          throws IOException
Deprecated. 
Returns the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Returns:
attribute byte, equals to attributes of FAT filesystems
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
setReadable, setWriteable, setHidden, getIsHidden, getCanWrite, getCanRead

setReadable

public static void setReadable(String fileName,
                               boolean readable)
                        throws IOException
Deprecated. 
Sets/resets the RO bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setWriteable, setHidden, getIsHidden, getCanWrite, getCanRead

setWriteable

public static void setWriteable(String fileName,
                                boolean readable)
                         throws IOException
Deprecated. 
Resets/sets the RO bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setReadable, setHidden, getIsHidden, getCanWrite, getCanRead

setHidden

public static void setHidden(String fileName,
                             boolean hidden)
                      throws IOException
Deprecated. 
Sets/resets the Hidden bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
hidden - value
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setReadable, setWriteable, getIsHidden, getCanWrite, getCanRead

getDirectorySize

public static long getDirectorySize(String directoryName)
                             throws IOException
Deprecated. 
Returns the size of a folder.

Throws:
IOException - if the directory doesn't exist or some other kind of I/O error occurs

getTotalSize

public static long getTotalSize(String fileName)
                         throws IOException
Deprecated. 
Returns the total size of a drive.

Parameters:
fileName - drive name
Throws:
IOException - if an I/O error occurs

truncate

public void truncate(int byteOffset)
              throws IOException
Deprecated. 
Truncates the file at offset.

Parameters:
byteOffset - offset in bytes
Throws:
IOException - if an I/O error occurs

truncateFile

public void truncateFile(int byteOffset)
                  throws IOException
Deprecated. 
Truncates the file at offset.

Parameters:
byteOffset - offset in bytes
Throws:
IOException - if an I/O error occurs

getIsHidden

public static boolean getIsHidden(String fileName)
                           throws IOException
Deprecated. 
Returns the Hidden bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setReadable, setWriteable, setHidden, getCanWrite, getCanRead

getCanWrite

public static boolean getCanWrite(String fileName)
                           throws IOException
Deprecated. 
Returns the complement of the RO bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setReadable, setWriteable, setHidden, getIsHidden, getCanRead

getCanRead

public static boolean getCanRead(String fileName)
                          throws IOException
Deprecated. 
Returns the RO bit of the attribute byte of a file or folder.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the file or directory doesn't exist or some other kind of I/O error occurs
See Also:
getAttributes, setReadable, setWriteable, setHidden, getIsHidden, getCanWrite

getLastModified

public static long getLastModified(String fileName)
                            throws IOException
Deprecated. 
Returns the time in seconds since last modification of the file or directory.

Parameters:
fileName - path and name to directory or file
Throws:
IOException - if the directory doesn't exist or some other kind of I/O error occurs

spaceAvailable

public static int spaceAvailable()
                          throws IOException
Deprecated. 
Returns the free disk space (in bytes), available on the MMC file system.

Returns:
available disk space in bytes
Throws:
IOException - if some kind of I/O error occurs

rename

public static void rename(String source,
                          String dest)
                   throws IOException
Deprecated. 
Renames a file from source filename to destination filename.

Parameters:
source - source name of the file
dest - destination name of the file
Throws:
IllegalArgumentException - if the path is invalid
IOException - if some kind of I/O error occurs
See Also:
exists, copy, delete

copy

public static void copy(String source,
                        String dest)
                 throws IOException
Deprecated. 
Performs a file copy.

Parameters:
source - name of the source file
dest - name of the destination file (the file copy)
Throws:
IllegalArgumentException - if the path of one of the arguments is invalid
IOException - if some kind of I/O error occurs
See Also:
exists, rename, delete

isDirectory

public static boolean isDirectory(String pathName)
                           throws IOException
Deprecated. 
Checks if the given path specifies a directory.

Parameters:
pathName - the name of the path to be checked
Returns:
true if pathName specifies a directory - false if it specifies a file
Throws:
IllegalArgumentException - if the path is invalid
IOException - if the given path doesn't exist or some other kind of I/O error occurs
See Also:
open, copy, rename, delete

list

public static String[] list(String pathName)
                     throws IOException
Deprecated. 
Lists the content of a directory.

Parameters:
pathName - path to directory to be listed
Returns:
array of strings containing the files and subdirectories within the path
Throws:
IllegalArgumentException - if the path is invalid
IOException - if the directory doesn't exist or some other kind of I/O error occurs or the number of directory entries exceeds 200.
See Also:
open, copy, rename, delete

list

public static String[] list(String pathName,
                            boolean includeHidden)
                     throws IOException
Deprecated. 
Lists the content of a directory.

Parameters:
pathName - path to directory to be listed
includeHidden - includes hidden files and directories
Returns:
array of strings containing the files and subdirectories within the path
Throws:
IllegalArgumentException - if the path is invalid
IOException - if the directory doesn't exist or some other kind of I/O error occurs or the number of directory entries exceeds 200.
See Also:
open, copy, rename, delete

isOpen

public boolean isOpen()
Deprecated. 
Return the open state of the file corresponding to the class instance.

Returns:
true if the file has been opened, and false if not

IM Profile

Submit a comment or suggestion Version 2.0 of IM Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.