public class MonitorRandomAccessContent extends Object implements RandomAccessContent
| Constructor and Description |
|---|
MonitorRandomAccessContent(RandomAccessContent content) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this content.
|
long |
getFilePointer()
Returns the current offset in this file.
|
InputStream |
getInputStream()
Get the input stream.
|
long |
length()
Returns the length of this file.
|
protected void |
onClose()
Called after this stream is closed.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
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 |
writeUTF(String str) |
public MonitorRandomAccessContent(RandomAccessContent content)
protected void onClose()
throws IOException
IOException - if subclass throws it.public void close()
throws IOException
close in interface RandomAccessContentIOException - if an error occurs.public long getFilePointer()
throws IOException
RandomAccessContentgetFilePointer in interface RandomAccessContentIOException - if an I/O error occurs.public void seek(long pos)
throws IOException
RandomAccessContentThe 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 calling
RandomAccessContent.seek(long)
seek in interface RandomAccessContentpos - the offset position, measured in bytes from the beginning of the file, at which to set the file
pointer.IOException - if pos is less than 0 or if an I/O error occurs.public long length()
throws IOException
RandomAccessContentlength in interface RandomAccessContentIOException - if an I/O error occurs.public void write(int b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in interface DataOutputIOExceptionpublic void writeBoolean(boolean v)
throws IOException
writeBoolean in interface DataOutputIOExceptionpublic void writeByte(int v)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeShort(int v)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeChar(int v)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeInt(int v)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeLong(long v)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeFloat(float v)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeDouble(double v)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputIOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeUTF(String str) throws IOException
writeUTF in interface DataOutputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionpublic void setLength(long newLength)
throws IOException
RandomAccessContent
If the the newLength argument is smaller than RandomAccessContent.length(), the content is truncated.
If the the newLength argument is greater than RandomAccessContent.length(), the content grows with undefined data.
setLength in interface RandomAccessContentnewLength - The desired content lengthIOException - If an I/O error occurspublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic InputStream getInputStream() throws IOException
RandomAccessContent
Notice: If you use RandomAccessContent.seek(long) you have to re-get the InputStream
getInputStream in interface RandomAccessContentIOException - if an I/O error occurs.Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.