Class SftpRandomAccessContent
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractRandomAccessContent
-
- org.apache.commons.vfs2.provider.AbstractRandomAccessStreamContent
-
- org.apache.commons.vfs2.provider.sftp.SftpRandomAccessContent
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.io.DataOutput
,java.lang.AutoCloseable
,RandomAccessContent
class SftpRandomAccessContent extends AbstractRandomAccessStreamContent
Random access content.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.DataInputStream
dis
private SftpFileObject
fileObject
protected long
filePointer
file pointerprivate java.io.InputStream
mis
-
Constructor Summary
Constructors Constructor Description SftpRandomAccessContent(SftpFileObject fileObject, RandomAccessMode mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this random access file stream and releases any system resources associated with the stream.protected java.io.DataInputStream
getDataInputStream()
long
getFilePointer()
Returns the current offset in this file.long
length()
Returns the length of this file.void
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractRandomAccessStreamContent
getInputStream, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, setLength, skipBytes
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractRandomAccessContent
readLine, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
-
-
-
Field Detail
-
filePointer
protected long filePointer
file pointer
-
fileObject
private final SftpFileObject fileObject
-
dis
private java.io.DataInputStream dis
-
mis
private java.io.InputStream mis
-
-
Constructor Detail
-
SftpRandomAccessContent
SftpRandomAccessContent(SftpFileObject fileObject, RandomAccessMode mode)
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Description copied from interface:RandomAccessContent
Closes this random access file stream and releases any system resources associated with the stream.A closed random access file cannot perform input or output operations and cannot be reopened.
If this file has an associated channel then the channel is closed as well.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
getDataInputStream
protected java.io.DataInputStream getDataInputStream() throws java.io.IOException
- Specified by:
getDataInputStream
in classAbstractRandomAccessStreamContent
- Throws:
java.io.IOException
-
getFilePointer
public long getFilePointer() throws java.io.IOException
Description copied from interface:RandomAccessContent
Returns the current offset in this file.- Returns:
- the offset from the beginning of the file, in bytes, at which the next read or write occurs.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
length
public long length() throws java.io.IOException
Description copied from interface:RandomAccessContent
Returns the length of this file.- Returns:
- the length of this file, measured in bytes.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
seek
public void seek(long pos) throws java.io.IOException
Description copied from interface:RandomAccessContent
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Notice: If you use
RandomAccessContent.getInputStream()
you have to re-get the InputStream after callingRandomAccessContent.seek(long)
- Parameters:
pos
- the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.- Throws:
java.io.IOException
- ifpos
is less than0
or if an I/O error occurs.
-
-