Package org.apache.commons.vfs2.provider
Class AbstractRandomAccessStreamContent
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractRandomAccessContent
-
- org.apache.commons.vfs2.provider.AbstractRandomAccessStreamContent
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.io.DataOutput
,java.lang.AutoCloseable
,RandomAccessContent
public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent
Implements the part usable for all stream-based random access.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRandomAccessStreamContent(RandomAccessMode mode)
Constructs a new instance for subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.io.DataInputStream
getDataInputStream()
Gets a DataInputStream.java.io.InputStream
getInputStream()
Gets the input stream.boolean
readBoolean()
byte
readByte()
char
readChar()
double
readDouble()
float
readFloat()
void
readFully(byte[] b)
void
readFully(byte[] b, int off, int len)
int
readInt()
long
readLong()
short
readShort()
int
readUnsignedByte()
int
readUnsignedShort()
java.lang.String
readUTF()
void
setLength(long newLength)
Sets the length of this content.int
skipBytes(int n)
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.vfs2.RandomAccessContent
close, getFilePointer, length, seek
-
-
-
-
Constructor Detail
-
AbstractRandomAccessStreamContent
protected AbstractRandomAccessStreamContent(RandomAccessMode mode)
Constructs a new instance for subclasses.- Parameters:
mode
- the RandomAccessMode.
-
-
Method Detail
-
getDataInputStream
protected abstract java.io.DataInputStream getDataInputStream() throws java.io.IOException
Gets a DataInputStream.- Returns:
- a DataInputStream.
- Throws:
java.io.IOException
- if an IO error occurs.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
Description copied from interface:RandomAccessContent
Gets the input stream.Notice: If you use
RandomAccessContent.seek(long)
you have to re-get the InputStream- Returns:
- the InputStream.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
readBoolean
public boolean readBoolean() throws java.io.IOException
- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException
- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException
- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException
- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException
- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b) throws java.io.IOException
- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException
- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException
- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException
- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException
- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException
- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException
- Throws:
java.io.IOException
-
setLength
public void setLength(long newLength) throws java.io.IOException
Description copied from interface:RandomAccessContent
Sets the length of this content.If the
newLength
argument is smaller thanRandomAccessContent.length()
, the content is truncated.If the
newLength
argument is greater thanRandomAccessContent.length()
, the content grows with undefined data.- Parameters:
newLength
- The desired content length- Throws:
java.io.IOException
- If an I/O error occurs
-
skipBytes
public int skipBytes(int n) throws java.io.IOException
- Throws:
java.io.IOException
-
-