Package net.metanotion.io
Class RAIFile
java.lang.Object
net.metanotion.io.RAIFile
- All Implemented Interfaces:
Closeable,DataInput,DataOutput,AutoCloseable,RandomAccessInterface
public class RAIFile extends Object implements RandomAccessInterface, DataInput, DataOutput
-
Constructor Summary
Constructors Constructor Description RAIFile(File file, boolean read, boolean write)RAIFile(RandomAccessFile file) -
Method Summary
Modifier and Type Method Description booleancanWrite()I2P is the file writable? Only valid if the File constructor was used, not the RAF constructorvoidclose()longgetFilePointer()longlength()intread()intread(byte[] b)intread(byte[] b, int off, int len)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()shortreadShort()intreadUnsignedByte()intreadUnsignedInt()I2PintreadUnsignedShort()StringreadUTF()Read a UTF encoded string I would delegate here.voidseek(long pos)voidsetLength(long newLength)intskipBytes(int n)StringtoString()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)voidwriteChar(int v)voidwriteChars(String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteShort(int v)voidwriteUTF(String str)Write a UTF encoded string I would delegate here.
-
Constructor Details
-
RAIFile
- Throws:
FileNotFoundException
-
RAIFile
- Parameters:
read- must be true- Throws:
FileNotFoundException
-
-
Method Details
-
canWrite
public boolean canWrite()I2P is the file writable? Only valid if the File constructor was used, not the RAF constructor- Specified by:
canWritein interfaceRandomAccessInterface- Since:
- 0.8.8
-
toString
-
getFilePointer
- Specified by:
getFilePointerin interfaceRandomAccessInterface- Throws:
IOException
-
length
- Specified by:
lengthin interfaceRandomAccessInterface- Throws:
IOException
-
read
- Specified by:
readin interfaceRandomAccessInterface- Throws:
IOException
-
read
- Specified by:
readin interfaceRandomAccessInterface- Throws:
IOException
-
read
- Specified by:
readin interfaceRandomAccessInterface- Throws:
IOException
-
seek
- Specified by:
seekin interfaceRandomAccessInterface- Throws:
IOException
-
setLength
- Specified by:
setLengthin interfaceRandomAccessInterface- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRandomAccessInterface- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Specified by:
readBooleanin interfaceRandomAccessInterface- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Specified by:
readBytein interfaceRandomAccessInterface- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Specified by:
readCharin interfaceRandomAccessInterface- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Specified by:
readDoublein interfaceRandomAccessInterface- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Specified by:
readFloatin interfaceRandomAccessInterface- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Specified by:
readFullyin interfaceRandomAccessInterface- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Specified by:
readFullyin interfaceRandomAccessInterface- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Specified by:
readIntin interfaceRandomAccessInterface- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Specified by:
readLinein interfaceRandomAccessInterface- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Specified by:
readLongin interfaceRandomAccessInterface- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Specified by:
readShortin interfaceRandomAccessInterface- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Specified by:
readUnsignedBytein interfaceRandomAccessInterface- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Specified by:
readUnsignedShortin interfaceRandomAccessInterface- Throws:
IOException
-
readUnsignedInt
I2P- Specified by:
readUnsignedIntin interfaceRandomAccessInterface- Throws:
IOException- if the read value is negative
-
readUTF
Read a UTF encoded string I would delegate here. But Java's read/writeUTF combo suck. A signed 2 byte length is not enough. This reads a 4 byte length. The upper byte MUST be zero, if its not, then its not this method and has used an extensible length encoding. This is followed by the bytes of the UTF encoded string, as returned by String.getBytes("UTF-8");- Specified by:
readUTFin interfaceDataInput- Specified by:
readUTFin interfaceRandomAccessInterface- Throws:
IOException
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Specified by:
skipBytesin interfaceRandomAccessInterface- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceRandomAccessInterface- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceRandomAccessInterface- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceRandomAccessInterface- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Specified by:
writeBooleanin interfaceRandomAccessInterface- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Specified by:
writeBytein interfaceRandomAccessInterface- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Specified by:
writeShortin interfaceRandomAccessInterface- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Specified by:
writeCharin interfaceRandomAccessInterface- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Specified by:
writeIntin interfaceRandomAccessInterface- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Specified by:
writeLongin interfaceRandomAccessInterface- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Specified by:
writeFloatin interfaceRandomAccessInterface- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Specified by:
writeDoublein interfaceRandomAccessInterface- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Specified by:
writeBytesin interfaceRandomAccessInterface- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Specified by:
writeCharsin interfaceRandomAccessInterface- Throws:
IOException
-
writeUTF
Write a UTF encoded string I would delegate here. But Java's read/writeUTF combo suck. A signed 2 byte length is not enough. This writes a 4 byte length. The upper byte MUST be zero, if its not, then its not this method and has used an extensible length encoding. This is followed by the bytes of the UTF encoded string, as returned by String.getBytes("UTF-8");- Specified by:
writeUTFin interfaceDataOutput- Specified by:
writeUTFin interfaceRandomAccessInterface- Throws:
IOException
-