public class XFileAccessor extends java.lang.Object implements XFileAccessor
XFile
Constructor and Description |
---|
XFileAccessor() |
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Tests if the application can read from the specified file.
|
boolean |
canWrite()
Tests if the application can write to this file.
|
void |
close()
Close the file
|
boolean |
delete()
Deletes the file specified by this object.
|
boolean |
exists()
Tests if this XFileAccessor object exists.
|
void |
flush()
Forces any buffered output bytes to be written out.
|
XFile |
getXFile()
Get the XFile for this Accessor
|
boolean |
isDirectory()
Tests if the file represented by this XFileAccessor
object is a directory.
|
boolean |
isFile()
Tests if the file represented by this
object is a "normal" file.
|
long |
lastModified()
Returns the time that the file represented by this
XFile object was last modified. |
long |
length()
Returns the length of the file represented by this
XFileAccessor object.
|
java.lang.String[] |
list()
Returns a list of the files in the directory specified by
this XFileAccessor object.
|
boolean |
mkdir()
Creates a directory whose pathname is specified by this
XFileAccessor object.
|
boolean |
mkfile()
Creates a file whose pathname is specified by this
XFileAccessor object.
|
boolean |
open(XFile xf,
boolean serial,
boolean readOnly)
Open this file object
|
int |
read(byte[] b,
int off,
int len,
long foff)
Reads a subarray as a sequence of bytes.
|
boolean |
renameTo(XFile dest)
Renames the file specified by this XFileAccessor object to
have the pathname given by the XFileAccessor object argument.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
void |
write(byte[] b,
int off,
int len,
long foff)
Writes a sub array as a sequence of bytes.
|
public boolean open(XFile xf, boolean serial, boolean readOnly)
open
in interface XFileAccessor
xf
- the XFile for this fileserial
- true if serial accessreadOnly
- true if read onlypublic XFile getXFile()
getXFile
in interface XFileAccessor
public boolean exists()
exists
in interface XFileAccessor
true
if the file specified by this object
exists; false
otherwise.public boolean canWrite()
canWrite
in interface XFileAccessor
true
if the application is allowed to
write to a file whose name is specified by this
object; false
otherwise.public boolean canRead()
canRead
in interface XFileAccessor
true
if the file specified by this
object exists and the application can read the file;
false
otherwise.public boolean isFile()
A file is "normal" if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
isFile
in interface XFileAccessor
true
if the file specified by this
XFile
object exists and is a "normal"
file; false
otherwise.public boolean isDirectory()
isDirectory
in interface XFileAccessor
true
if this XFileAccessor object
exists and is a directory; false
otherwise.public long lastModified()
XFile
object was last modified.
The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.
lastModified
in interface XFileAccessor
0L
if the specified file
does not exist.public long length()
length
in interface XFileAccessor
0L
if the specified
file does not exist.public boolean mkfile()
mkfile
in interface XFileAccessor
true
if the file could be created;
false
otherwise.public boolean mkdir()
mkdir
in interface XFileAccessor
true
if the directory could be created;
false
otherwise.public boolean renameTo(XFile dest)
renameTo
in interface XFileAccessor
dest
- the new filename.true
if the renaming succeeds;
false
otherwise.public java.lang.String[] list()
list
in interface XFileAccessor
.
" and
"..
" on Unix systems).public boolean delete()
delete
in interface XFileAccessor
true
if the file is successfully deleted;
false
otherwise.public int read(byte[] b, int off, int len, long foff) throws java.io.IOException
read
in interface XFileAccessor
b
- the data to be writtenoff
- the start offset in the datalen
- the number of bytes that are writtenfoff
- the offset into the filejava.io.IOException
- If an I/O error has occurred.public void write(byte[] b, int off, int len, long foff) throws java.io.IOException
write
in interface XFileAccessor
b
- the data to be writtenoff
- the start offset in the datalen
- the number of bytes that are writtenfoff
- the offset into the filejava.io.IOException
- If an I/O error has occurred.public void flush() throws java.io.IOException
Since RandomAccessFile has no corresponding method this does nothing.
flush
in interface XFileAccessor
java.io.IOException
- if an I/O error occurs.public void close() throws java.io.IOException
close
in interface XFileAccessor
java.io.IOException
- If an I/O error has occurred.public java.lang.String toString()
toString
in class java.lang.Object