|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gnu.jcifs.CifsRandomAccessFile
The CifsRandomAccessFile
class allows reading and writing
data from and to any specified location in a file. This class does not
use any buffers, all read and write operations are performed remotely.
Constructor Summary | |
CifsRandomAccessFile(CifsDisk disk,
java.lang.String file,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to write to, a file with the specified name. |
|
CifsRandomAccessFile(CifsFile file,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to write to, a file with the specified name. |
|
CifsRandomAccessFile(java.lang.String sessionname,
java.lang.String file,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to write to, a file with the specified name. |
Method Summary | |
void |
close()
Closes the input file |
void |
finalize()
Finalizes this object |
CifsDisk |
getDisk()
Returns the disk on which the file resides |
long |
getFilePointer()
Returns the current offset in this file. |
long |
length()
Returns the length of this file. |
int |
read(byte[] b,
int off,
int len)
Reads bytes from the current offset |
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
void |
setLength(long newLength)
Sets the length of this file. |
int |
skipBytes(int n)
Attempts to skip over n bytes of input discarding the
skipped bytes.
|
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this file. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public CifsRandomAccessFile(CifsDisk disk, java.lang.String file, java.lang.String mode) throws java.io.IOException
The mode argument must either be equal to "r"
or
"rw"
, indicating that the file is to be opened for
input only or for both input and output, respectively. The
write methods on this object will always throw an
IOException
if the file is opened with a mode of
"r"
. If the mode is "rw"
and the
file does not exist, then an attempt is made to create it.
disk
- disk sessionfile
- file namemode
- the access mode."r"
or to "rw"
.public CifsRandomAccessFile(java.lang.String sessionname, java.lang.String file, java.lang.String mode) throws java.io.IOException
The mode argument must either be equal to "r"
or
"rw"
, indicating that the file is to be opened for
input only or for both input and output, respectively. The
write methods on this object will always throw an
IOException
if the file is opened with a mode of
"r"
. If the mode is "rw"
and the
file does not exist, then an attempt is made to create it.
sessionname
- disk session namefile
- file namemode
- the access mode."r"
or to "rw"
.public CifsRandomAccessFile(CifsFile file, java.lang.String mode) throws java.io.IOException
The mode argument must either be equal to "r"
or
"rw"
, indicating that the file is to be opened for
input only or for both input and output, respectively. The
write methods on this object will always throw an
IOException
if the file is opened with a mode of
"r"
. If the mode is "rw"
and the
file does not exist, then an attempt is made to create it.
file
- file objectmode
- the access mode."r"
or to "rw"
.Method Detail |
public long length()
public void setLength(long newLength) throws java.io.IOException
If the present length of the file as returned by the
length
method is greater than the newLength
argument then the file will be truncated. In this case, if the file
offset as returned by the getFilePointer
method is greater
then newLength
then after this method returns the offset
will be equal to newLength
.
If the present length of the file as returned by the
length
method is smaller than the newLength
argument then the file will be extended. In this case, the contents of
the extended portion of the file are not defined.
newLength
- The desired length of the filepublic CifsDisk getDisk() throws java.io.IOException
public void close() throws java.io.IOException
public long getFilePointer() throws java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
b
- destination buffer.off
- offset at which to start storing bytes.len
- maximum number of bytes to read.-1
if the end of
the stream has been reached.public void write(byte[] b, int off, int len) throws java.io.IOException
len
bytes from the specified byte array
starting at offset off
to this file.b
- the data.off
- the start offset in the data.len
- the number of bytes to write.public int skipBytes(int n) throws java.io.IOException
n
bytes of input discarding the
skipped bytes.
This method may skip over some smaller number of bytes, possibly zero.
This may result from any of a number of conditions; reaching end of
file before n
bytes have been skipped is only one
possibility. This method never throws an EOFException
.
The actual number of bytes skipped is returned. If n
is negative, no bytes are skipped.
n
- the number of bytes to be skipped.public void seek(long pos) throws java.io.IOException
pos
- the offset position, measured in bytes from the
beginning of the file, at which to set the file
pointer.pos
is less than
0
or if an I/O error occurs.public void finalize()
|
Norbert Hranitzky | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |