Class RamFileRandomAccessContent
- All Implemented Interfaces:
- Closeable,- DataInput,- DataOutput,- AutoCloseable,- RandomAccessContent
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionRamFileRandomAccessContent(RamFileObject file, RandomAccessMode mode) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes this random access file stream and releases any system resources associated with the stream.longReturns the current offset in this file.Gets the input stream.longlength()Returns the length of this file.booleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()readLine()longreadLong()shortintintreadUTF()voidseek(long pos) Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.voidsetLength(long newLength) Sets the length of this content.intskipBytes(int n) static byte[]toBytes(long n, byte[] b) Build an 8-byte array from a long.static longtoLong(byte[] b) Build a long from first 8 bytes of the array.static shorttoShort(byte[] b) Build a short from first 2 bytes of the array.static inttoUnsignedShort(byte[] b) Build a short from first 2 bytes of the array.voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwriteBoolean(boolean v) voidwriteByte(int i) voidwriteBytes(String s) voidwriteChar(int v) voidwriteChars(String s) voidwriteDouble(double v) voidwriteFloat(float v) voidwriteInt(int v) voidwriteLong(long v) voidwriteShort(int v) void
- 
Field Details- 
filePointerFile Pointer
 
- 
- 
Constructor Details- 
RamFileRandomAccessContentConstructs a new instance.- Parameters:
- file- The file to access.
- mode- The access mode.
 
 
- 
- 
Method Details- 
toBytesBuild an 8-byte array from a long. No check is performed on the array length.- Parameters:
- n- The number to convert.
- b- The array to fill.
- Returns:
- A byte[].
 
- 
toLongBuild a long from first 8 bytes of the array.- Parameters:
- b- The byte[] to convert.
- Returns:
- A long.
 
- 
toShortBuild a short from first 2 bytes of the array.- Parameters:
- b- The byte[] to convert.
- Returns:
- A short.
 
- 
toUnsignedShortBuild a short from first 2 bytes of the array.- Parameters:
- b- The byte[] to convert.
- Returns:
- A short.
 
- 
closeDescription copied from interface:RandomAccessContentCloses 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. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- RandomAccessContent
- Throws:
- IOException- if an I/O error occurs.
 
- 
getFilePointerDescription copied from interface:RandomAccessContentReturns the current offset in this file.- Specified by:
- getFilePointerin interface- RandomAccessContent
- 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.
 
- 
getInputStreamDescription copied from interface:RandomAccessContentGets the input stream.Notice: If you use RandomAccessContent.seek(long)you have to re-get the InputStream- Specified by:
- getInputStreamin interface- RandomAccessContent
- Returns:
- the InputStream.
- Throws:
- IOException- if an I/O error occurs.
 
- 
lengthDescription copied from interface:RandomAccessContentReturns the length of this file.- Specified by:
- lengthin interface- RandomAccessContent
- Returns:
- the length of this file, measured in bytes.
- Throws:
- IOException- if an I/O error occurs.
 
- 
readBoolean- Specified by:
- readBooleanin interface- DataInput
- Throws:
- IOException
 
- 
readByte- Specified by:
- readBytein interface- DataInput
- Throws:
- IOException
 
- 
readChar- Specified by:
- readCharin interface- DataInput
- Throws:
- IOException
 
- 
readDouble- Specified by:
- readDoublein interface- DataInput
- Throws:
- IOException
 
- 
readFloat- Specified by:
- readFloatin interface- DataInput
- Throws:
- IOException
 
- 
readFully- Specified by:
- readFullyin interface- DataInput
- Throws:
- IOException
 
- 
readFully- Specified by:
- readFullyin interface- DataInput
- Throws:
- IOException
 
- 
readInt- Specified by:
- readIntin interface- DataInput
- Throws:
- IOException
 
- 
readLine- Specified by:
- readLinein interface- DataInput
- Throws:
- IOException
 
- 
readLong- Specified by:
- readLongin interface- DataInput
- Throws:
- IOException
 
- 
readShort- Specified by:
- readShortin interface- DataInput
- Throws:
- IOException
 
- 
readUnsignedByte- Specified by:
- readUnsignedBytein interface- DataInput
- Throws:
- IOException
 
- 
readUnsignedShort- Specified by:
- readUnsignedShortin interface- DataInput
- Throws:
- IOException
 
- 
readUTF- Specified by:
- readUTFin interface- DataInput
- Throws:
- IOException
 
- 
seekDescription copied from interface:RandomAccessContentSets 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:
- seekin interface- RandomAccessContent
- Parameters:
- pos- the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
- Throws:
- IOException- if- posis less than- 0or if an I/O error occurs.
 
- 
setLengthDescription copied from interface:RandomAccessContentSets the length of this content.If the newLengthargument is smaller thanRandomAccessContent.length(), the content is truncated.If the newLengthargument is greater thanRandomAccessContent.length(), the content grows with undefined data.- Specified by:
- setLengthin interface- RandomAccessContent
- Parameters:
- newLength- The desired content length
- Throws:
- IOException- If an I/O error occurs
 
- 
skipBytes- Specified by:
- skipBytesin interface- DataInput
- Throws:
- IOException
 
- 
write- Specified by:
- writein interface- DataOutput
- Throws:
- IOException
 
- 
write- Specified by:
- writein interface- DataOutput
- Throws:
- IOException
 
- 
write- Specified by:
- writein interface- DataOutput
- Throws:
- IOException
 
- 
writeBoolean- Specified by:
- writeBooleanin interface- DataOutput
- Throws:
- IOException
 
- 
writeByte- Specified by:
- writeBytein interface- DataOutput
- Throws:
- IOException
 
- 
writeBytes- Specified by:
- writeBytesin interface- DataOutput
- Throws:
- IOException
 
- 
writeChar- Specified by:
- writeCharin interface- DataOutput
- Throws:
- IOException
 
- 
writeChars- Specified by:
- writeCharsin interface- DataOutput
- Throws:
- IOException
 
- 
writeDouble- Specified by:
- writeDoublein interface- DataOutput
- Throws:
- IOException
 
- 
writeFloat- Specified by:
- writeFloatin interface- DataOutput
- Throws:
- IOException
 
- 
writeInt- Specified by:
- writeIntin interface- DataOutput
- Throws:
- IOException
 
- 
writeLong- Specified by:
- writeLongin interface- DataOutput
- Throws:
- IOException
 
- 
writeShort- Specified by:
- writeShortin interface- DataOutput
- Throws:
- IOException
 
- 
writeUTF- Specified by:
- writeUTFin interface- DataOutput
- Throws:
- IOException
 
 
-