Package org.apache.commons.vfs2.util
Class MonitorRandomAccessContent
java.lang.Object
org.apache.commons.vfs2.util.MonitorRandomAccessContent
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
,RandomAccessContent
A RandomAccessContent that provides end-of-stream monitoring.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this content.long
Returns the current offset in this file.Gets the input stream.long
length()
Returns the length of this file.protected void
onClose()
Called after this stream is closed.boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
readLine()
long
readLong()
short
int
int
readUTF()
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 content.int
skipBytes
(int n) void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) void
writeBoolean
(boolean v) void
writeByte
(int v) void
writeBytes
(String s) void
writeChar
(int v) void
writeChars
(String s) void
writeDouble
(double v) void
writeFloat
(float v) void
writeInt
(int v) void
writeLong
(long v) void
writeShort
(int v) void
-
Constructor Details
-
MonitorRandomAccessContent
Constructs a new instance.- Parameters:
content
- The contents.
-
-
Method Details
-
close
Closes this content.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceRandomAccessContent
- Throws:
IOException
- if an error occurs.
-
getFilePointer
Description copied from interface:RandomAccessContent
Returns the current offset in this file.- Specified by:
getFilePointer
in interfaceRandomAccessContent
- Returns:
- the offset from the beginning of the file, in bytes, at which the next read or write occurs.
- Throws:
IOException
- if an I/O error occurs.
-
getInputStream
Description copied from interface:RandomAccessContent
Gets the input stream.Notice: If you use
RandomAccessContent.seek(long)
you have to re-get the InputStream- Specified by:
getInputStream
in interfaceRandomAccessContent
- Returns:
- the InputStream.
- Throws:
IOException
- if an I/O error occurs.
-
length
Description copied from interface:RandomAccessContent
Returns the length of this file.- Specified by:
length
in interfaceRandomAccessContent
- Returns:
- the length of this file, measured in bytes.
- Throws:
IOException
- if an I/O error occurs.
-
onClose
Called after this stream is closed.- Throws:
IOException
- if subclass throws it.
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLine
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
seek
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)
- Specified by:
seek
in interfaceRandomAccessContent
- Parameters:
pos
- the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.- Throws:
IOException
- ifpos
is less than0
or if an I/O error occurs.
-
setLength
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.- Specified by:
setLength
in interfaceRandomAccessContent
- Parameters:
newLength
- The desired content length- Throws:
IOException
- If an I/O error occurs
-
skipBytes
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-