com.sun.file
Class XFileAccessor
java.lang.Object
com.sun.file.XFileAccessor
- XFileAccessor
public class XFileAccessor
extends java.lang.Object
The XFileAccessor interface is implemented by filesystems that
need to be accessed via the XFile API.
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.
|
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(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.
|
String | toString() - Returns a string representation of this object.
|
void | write(b[] , int off, int len, long foff) - Writes a sub array as a sequence of bytes.
|
canRead
public boolean canRead()
Tests if the application can read from the specified file.
- canRead in interface XFileAccessor
true
if the file specified by this
object exists and the application can read the file;
false
otherwise.
canWrite
public boolean canWrite()
Tests if the application can write to this file.
- canWrite in interface XFileAccessor
true
if the application is allowed to
write to a file whose name is specified by this
object; false
otherwise.
close
public void close()
throws IOException
Close the file
- close in interface XFileAccessor
delete
public boolean delete()
Deletes the file specified by this object. If the target
file to be deleted is a directory, it must be empty for
deletion to succeed.
- delete in interface XFileAccessor
true
if the file is successfully deleted;
false
otherwise.
exists
public boolean exists()
Tests if this XFileAccessor object exists.
- exists in interface XFileAccessor
true
if the file specified by this object
exists; false
otherwise.
flush
public void flush()
throws IOException
Forces any buffered output bytes to be written out.
Since RandomAccessFile has no corresponding method
this does nothing.
- flush in interface XFileAccessor
isDirectory
public boolean isDirectory()
Tests if the file represented by this XFileAccessor
object is a directory.
- isDirectory in interface XFileAccessor
true
if this XFileAccessor object
exists and is a directory; false
otherwise.
isFile
public boolean isFile()
Tests if the file represented by this
object is a "normal" file.
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.
lastModified
public long lastModified()
Returns the time that the file represented by this
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
- the time the file specified by this object was last
modified, or
0L
if the specified file
does not exist.
length
public long length()
Returns the length of the file represented by this
XFileAccessor object.
- length in interface XFileAccessor
- the length, in bytes, of the file specified by
this object, or
0L
if the specified
file does not exist.
list
public String[] list()
Returns a list of the files in the directory specified by
this XFileAccessor object.
- list in interface XFileAccessor
- an array of file names in the specified directory.
This list does not include the current directory or
the parent directory ("
.
" and
"..
" on Unix systems).
mkdir
public boolean mkdir()
Creates a directory whose pathname is specified by this
XFileAccessor object.
- mkdir in interface XFileAccessor
true
if the directory could be created;
false
otherwise.
mkfile
public boolean mkfile()
Creates a file whose pathname is specified by this
XFileAccessor object.
- mkfile in interface XFileAccessor
true
if the file could be created;
false
otherwise.
open
public boolean open(XFile xf,
boolean serial,
boolean readOnly)
Open this file object
- open in interface XFileAccessor
xf
- the XFile for this fileserial
- true if serial accessreadOnly
- true if read only
read
public int read(b[] ,
int off,
int len,
long foff)
throws IOException
Reads a subarray as a sequence of bytes.
- read in interface XFileAccessor
off
- the start offset in the datalen
- the number of bytes that are writtenfoff
- the offset into the file
- number of bytes read; -1 if EOF
renameTo
public boolean renameTo(XFile dest)
Renames the file specified by this XFileAccessor object to
have the pathname given by the XFileAccessor object argument.
- renameTo in interface XFileAccessor
true
if the renaming succeeds;
false
otherwise.
toString
public String toString()
Returns a string representation of this object.
- a string giving the pathname of this object.
write
public void write(b[] ,
int off,
int len,
long foff)
throws IOException
Writes a sub array as a sequence of bytes.
- write in interface XFileAccessor
off
- the start offset in the datalen
- the number of bytes that are writtenfoff
- the offset into the file