Package com.sun.http
Class XFileAccessor
- java.lang.Object
-
- com.sun.http.XFileAccessor
-
- All Implemented Interfaces:
XFileAccessor
public class XFileAccessor extends java.lang.Object implements XFileAccessor
The XFileAccessor interface is implemented by filesystems that need to be accessed via the XFile API.- Version:
- 1.0, 04/08/98
- Author:
- Brent Callaghan
- See Also:
XFile
-
-
Constructor Summary
Constructors Constructor Description XFileAccessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRead()Tests if the application can read from the specified file.booleancanWrite()Tests if the application can write to this file.voidclose()Close the Streamsbooleandelete()Deletes the file specified by this object.booleanexists()Tests if this XFileAccessor object exists.voidflush()Forces any buffered output bytes to be written out.XFilegetXFile()Get the XFile for this AccessorbooleanisDirectory()Tests if the file represented by this XFileAccessor object is a directory.booleanisFile()Tests if the file represented by this object is a "normal" file.longlastModified()Returns the time that the file represented by thisXFileobject was last modified.longlength()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.booleanmkdir()Creates a directory whose pathname is specified by this XFileAccessor object.booleanmkfile()Creates a file whose pathname is specified by this XFileAccessor object.booleanopen(XFile xf, boolean serial, boolean readOnly)Open this file objectintread(byte[] b, int off, int len, long foff)Reads a subarray as a sequence of bytes.booleanrenameTo(XFile dest)Renames the file specified by this XFileAccessor object to have the pathname given by the XFileAccessor object argument.java.lang.StringtoString()Returns a string representation of this object.voidwrite(byte[] b, int off, int len, long foff)Writes a sub array as a sequence of bytes.
-
-
-
Method Detail
-
open
public boolean open(XFile xf, boolean serial, boolean readOnly)
Open this file object- Specified by:
openin interfaceXFileAccessor- Parameters:
xf- the XFile for this fileserial- true if serial accessreadOnly- true if read only
-
getXFile
public XFile getXFile()
Get the XFile for this Accessor- Specified by:
getXFilein interfaceXFileAccessor- Returns:
- XFile for this object
-
exists
public boolean exists()
Tests if this XFileAccessor object exists.- Specified by:
existsin interfaceXFileAccessor- Returns:
trueif the file specified by this object exists;falseotherwise.
-
canWrite
public boolean canWrite()
Tests if the application can write to this file.- Specified by:
canWritein interfaceXFileAccessor- Returns:
trueif the application is allowed to write to a file whose name is specified by this object;falseotherwise.
-
canRead
public boolean canRead()
Tests if the application can read from the specified file.- Specified by:
canReadin interfaceXFileAccessor- Returns:
trueif the file specified by this object exists and the application can read the file;falseotherwise.
-
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.
- Specified by:
isFilein interfaceXFileAccessor- Returns:
trueif the file specified by thisXFileobject exists and is a "normal" file;falseotherwise.
-
isDirectory
public boolean isDirectory()
Tests if the file represented by this XFileAccessor object is a directory.- Specified by:
isDirectoryin interfaceXFileAccessor- Returns:
trueif this XFileAccessor object exists and is a directory;falseotherwise.
-
lastModified
public long lastModified()
Returns the time that the file represented by thisXFileobject 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.
- Specified by:
lastModifiedin interfaceXFileAccessor- Returns:
- the time the file specified by this object was last
modified, or
0Lif the specified file does not exist.
-
length
public long length()
Returns the length of the file represented by this XFileAccessor object.- Specified by:
lengthin interfaceXFileAccessor- Returns:
- the length, in bytes, of the file specified by
this object, or
0Lif the specified file does not exist.
-
mkfile
public boolean mkfile()
Creates a file whose pathname is specified by this XFileAccessor object.- Specified by:
mkfilein interfaceXFileAccessor- Returns:
trueif the file could be created;falseotherwise.
-
mkdir
public boolean mkdir()
Creates a directory whose pathname is specified by this XFileAccessor object.- Specified by:
mkdirin interfaceXFileAccessor- Returns:
trueif the directory could be created;falseotherwise.
-
renameTo
public boolean renameTo(XFile dest)
Renames the file specified by this XFileAccessor object to have the pathname given by the XFileAccessor object argument.- Specified by:
renameToin interfaceXFileAccessor- Parameters:
dest- the new filename.- Returns:
trueif the renaming succeeds;falseotherwise.
-
list
public java.lang.String[] list()
Returns a list of the files in the directory specified by this XFileAccessor object.- Specified by:
listin interfaceXFileAccessor- Returns:
- 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).
-
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.- Specified by:
deletein interfaceXFileAccessor- Returns:
trueif the file is successfully deleted;falseotherwise.
-
read
public int read(byte[] b, int off, int len, long foff) throws java.io.IOExceptionReads a subarray as a sequence of bytes.- Specified by:
readin interfaceXFileAccessor- Parameters:
b- the data to be writtenoff- the start offset in the datalen- the number of bytes that are writtenfoff- the offset into the file- Returns:
- number of bytes read; -1 if EOF
- Throws:
java.io.IOException- If an I/O error has occurred.
-
write
public void write(byte[] b, int off, int len, long foff) throws java.io.IOExceptionWrites a sub array as a sequence of bytes.- Specified by:
writein interfaceXFileAccessor- Parameters:
b- the data to be writtenoff- the start offset in the datalen- the number of bytes that are writtenfoff- the offset into the file- Throws:
java.io.IOException- If an I/O error has occurred.
-
flush
public void flush() throws java.io.IOExceptionForces any buffered output bytes to be written out.- Specified by:
flushin interfaceXFileAccessor- Throws:
java.io.IOException- if an I/O error occurs.
-
close
public void close() throws java.io.IOExceptionClose the Streams- Specified by:
closein interfaceXFileAccessor- Throws:
java.io.IOException- If an I/O error has occurred.
-
toString
public java.lang.String toString()
Returns a string representation of this object.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string giving the pathname of this object.
-
-