phelps.io

Class ByteArrayRAF

public class ByteArrayRAF extends Object implements RandomAccess

A RandomAccessFile interface to a byte[], in the same way java.io.ByteArrayInputStream provides an InputStream interface.

Does not subclass java.io.RandomAccessFile because we want to use this class in restriced situations where reading of local files is not permitted and RAF always checks the readability of its file.

See Also: BufferedRandomAccessFile

Constructor Summary
ByteArrayRAF(byte[] buf, String mode)
ByteArrayRAF(InputStream in, String mode)
Sets contents from remainder of in and closes in.
Method Summary
voidclose()
byte[]getByteArray()
longgetFilePointer()
longlength()
intread(byte[] b)
intread(byte[] b, int off, int len)
intread()
voidreadFully(byte[] b)
voidreadFully(byte[] b, int off, int len)
voidseek(long pos)
voidsetLength(long newLength)
intskipBytes(int n)
voidwrite(byte[] b)
voidwrite(byte[] b, int off, int len)
voidwrite(int b)
voidwriteChar(char ch)
voidwriteString16(String s)
voidwriteString8(String s)

Constructor Detail

ByteArrayRAF

public ByteArrayRAF(byte[] buf, String mode)

ByteArrayRAF

public ByteArrayRAF(InputStream in, String mode)
Sets contents from remainder of in and closes in.

Method Detail

close

public void close()

getByteArray

public byte[] getByteArray()

getFilePointer

public long getFilePointer()

length

public long length()

read

public int read(byte[] b)

read

public int read(byte[] b, int off, int len)

read

public int read()

readFully

public void readFully(byte[] b)

readFully

public void readFully(byte[] b, int off, int len)

seek

public void seek(long pos)

setLength

public void setLength(long newLength)

skipBytes

public int skipBytes(int n)

write

public void write(byte[] b)

write

public void write(byte[] b, int off, int len)

write

public void write(int b)

writeChar

public void writeChar(char ch)

writeString16

public void writeString16(String s)

writeString8

public void writeString8(String s)