kAWT Version 0.90

java.io
Class File

java.lang.Object
  |
  +--java.io.File

public class File
extends Object

An abstract representation of file and directory pathnames based on com.sun.kjava.Database.

The kAWT FileDB Format:
The IO extension of kAWT contains a hierarchical file system simulation based on a regular Palm memory database. Storing clusters on a Palm is done inside a database called "TrantorFileDB" with creatorID/typeID = KAWT/FILE

Record Structure:
The first record (#0) in the FileDB contains the cluster table of the root directory. The second record contains a list of unused records.

Files:
Files consist of a cluster table and one or more data records. The data records have a fixed size of 512 bytes.

Cluster Tables:
The first four bytes of the cluster table contain the current file length in Motorola format. The file length is followed by (filesize / 512) two-byte entries. These entries are pointers to the 512-byte records containing the actual file data.

Directories:
Directories are organized like simple files. The directory file contains a list of filenames and cluster table record pointers. The directory entires start with a letter (D/F), denoting the type of the entry. If the letter is a "D", the entry points to a directory. If the letter is a "F", the entry points to a simple file. The type letter is followed by a space and the local name of the file. The file name is followed by a space. The space is followed by the record number of the cluster table of the file. The record number is encoded in decimal format. The entry is terminated by a newline character (#10, 0x0A).


Field Summary
static String separator
          The system-dependent default name-separator character, represented as a string for convenience.
static char separatorChar
          The system-dependent default name-separator character.
 
Constructor Summary
File(File parent, String child)
          Creates a new File instance from a parent abstract pathname and a child pathname string.
File(String pathname)
          Creates a new File instance by converting the given pathname string into an abstract pathname.
File(String parent, String child)
          Creates a new File instance from a parent pathname string and a child pathname string.
 
Method Summary
 boolean delete()
          Deletes the file or directory denoted by this abstract pathname.
 String getCanonicalPath()
          Returns the canonical pathname string of this abstract pathname.
 String getName()
          Returns the name of the file or directory denoted by this abstract pathname.
 boolean isDirectory()
          Tests whether the file denoted by this abstract pathname is a directory.
 long length()
          Returns the length of the file denoted by this abstract pathname.
 String[] list()
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
 File[] listFiles()
          Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
 boolean mkdir()
          Creates the directory named by this abstract pathname.
 String toString()
          Returns the pathname string of this abstract pathname.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

separator

public static String separator
The system-dependent default name-separator character, represented as a string for convenience.

separatorChar

public static char separatorChar
The system-dependent default name-separator character.
Constructor Detail

File

public File(File parent,
            String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
Parameters:
parent - - The parent abstract pathname
child - - The child pathname string

File

public File(String parent,
            String child)
Creates a new File instance from a parent pathname string and a child pathname string.
Parameters:
parent - - The parent pathname string
child - - The child pathname string

File

public File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.
Parameters:
pathname - - A pathname string
Method Detail

delete

public boolean delete()
Deletes the file or directory denoted by this abstract pathname.
Returns:
true if and only if the file or directory is successfully deleted; false otherwise

getCanonicalPath

public String getCanonicalPath()
                        throws IOException
Returns the canonical pathname string of this abstract pathname.
Returns:
The canonical pathname string denoting the same file or directory as this abstract pathname
Throws:
IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

getName

public String getName()
Returns the name of the file or directory denoted by this abstract pathname.
Returns:
The name of the file or directory denoted by this abstract pathname, or the empty string if this pathname's name sequence is empty

isDirectory

public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.
Returns:
true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise

list

public String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

length

public long length()
Returns the length of the file denoted by this abstract pathname.
Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist

listFiles

public File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

mkdir

public boolean mkdir()
Creates the directory named by this abstract pathname.
Returns:
true if and only if the directory was created, along with all necessary parent directories; false otherwise

toString

public String toString()
Returns the pathname string of this abstract pathname. This is just the string returned by the getPath() method.
Overrides:
toString in class Object
Returns:
The string form of this abstract pathname

kAWT Version 0.90