|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.io.Stream | +--waba.io.File
File is a file or directory.
The File class will not work under the PalmPilot since it does not contain a filesystem.
Here is an example showing data being read from a file:
File file = new File("/temp/tempfile", File.READ_ONLY); if (!file.isOpen()) return; byte b[] = new byte[10]; file.readBytes(b, 0, 10); file.close(); file = new File("/temp/tempfile", File.DONT_OPEN); file.delete();
Field Summary | |
static int |
CREATE
Create open mode. |
static int |
DONT_OPEN
Don't open the file mode. |
static int |
READ_ONLY
Read-only open mode. |
static int |
READ_WRITE
Read-write open mode. |
static int |
WRITE_ONLY
Write-only open mode. |
Constructor Summary | |
File(java.lang.String path,
int mode)
Opens a file with the given name and mode. |
Method Summary | |
boolean |
close()
Closes the file. |
boolean |
createDir()
Creates a directory. |
boolean |
delete()
Deletes the file or directory. |
boolean |
exists()
Returns true if the file exists and false otherwise. |
int |
getLength()
Returns the length of the file in bytes. |
java.lang.String |
getPath()
Return the file's path. |
boolean |
isDir()
Returns true if the file is a directory and false otherwise. |
boolean |
isOpen()
Returns true if the file is open for reading or writing and false otherwise. |
java.lang.String[] |
listDir()
Lists the files contained in a directory. |
int |
readBytes(byte[] b,
int off,
int len)
Reads bytes from the file into a byte array. |
boolean |
rename(java.lang.String path)
Renames the file. |
boolean |
seek(int pos)
Sets the file pointer for read and write operations to the given position. |
int |
writeBytes(byte[] b,
int off,
int len)
Writes to the file. |
Methods inherited from class java.lang.Object |
hashCode,
toString |
Field Detail |
public static final int DONT_OPEN
public static final int READ_ONLY
public static final int WRITE_ONLY
public static final int READ_WRITE
public static final int CREATE
Constructor Detail |
public File(java.lang.String path, int mode)
path
- the file's pathmode
- one of DONT_OPEN, READ_ONLY, WRITE_ONLY, READ_WRITE or CREATEMethod Detail |
public boolean close()
public boolean isOpen()
public boolean createDir()
public boolean delete()
public boolean exists()
public int getLength()
public java.lang.String getPath()
public boolean isDir()
public java.lang.String[] listDir()
public int readBytes(byte[] b, int off, int len)
buf
- the byte array to read data intostart
- the start position in the arraycount
- the number of bytes to readpublic int writeBytes(byte[] b, int off, int len)
buf
- the byte array to write data fromstart
- the start position in the byte arraycount
- the number of bytes to writepublic boolean rename(java.lang.String path)
public boolean seek(int pos)
file.seek(file.getLength());True is returned if the operation is successful and false otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |