|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.util.QSIO
The QSIO
class contains general utility methods for
writing/reading QuickSerializable
object to/from files.
Constructor Summary | |
---|---|
QSIO()
|
Method Summary | |
---|---|
static QuickSerializable |
bytesToQS(byte[] bytes)
The inverse of qsToBytes, above. |
static void |
delete(RandomAccessFile file,
long pos)
delete the contents of a QuickSerializable by filling where the object was with 0's |
static byte[] |
qsToBytes(QuickSerializable object)
|
static QuickSerializable |
read(InputStream in)
Read in the QuickSerializable stored in the specified
InputStream . |
static QuickSerializable |
read(RandomAccessFile file,
long pos)
Read in the QuickSerializable stored in the specified
RandomAccessFile . |
static QuickSerializable |
read(String filename)
Read in the QuickSerializable stored in the named file. |
static void |
write(QuickSerializable object,
OutputStream out)
Write a QuickSerializable object to the specified
OutputStream .
|
static void |
write(QuickSerializable object,
RandomAccessFile file,
long pos)
|
static void |
write(QuickSerializable object,
String filename)
Write a QuickSerializable to the named file
The file will be overwritten unless an IOException is
thrown, in which case the file will remain unmodified. |
static void |
write(QuickSerializable object,
String filename,
boolean append)
Write a QuickSerializable to the named file
This method provides no guarantees against file corruption if an
IOException is thrown during the write. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QSIO()
Method Detail |
public static void write(QuickSerializable object, OutputStream out) throws IOException
QuickSerializable
object to the specified
OutputStream
.
An 8B header is written first, containing the size of the object in
bytes, followed by its type code.
object
- The QuickSerializable
object to write.out
- The OutputStream
into which to write.
IOException
- if an I/O error occurs.public static byte[] qsToBytes(QuickSerializable object)
public static QuickSerializable bytesToQS(byte[] bytes) throws QSException
QSException
public static void write(QuickSerializable object, String filename) throws IOException
QuickSerializable
to the named file
The file will be overwritten unless an IOException
is
thrown, in which case the file will remain unmodified.
object
- The QuickSerializable
object to write.filename
- The name of the file into which to write.
IOException
- if an I/O error occurs.public static void write(QuickSerializable object, String filename, boolean append) throws IOException
QuickSerializable
to the named file
This method provides no guarantees against file corruption if an
IOException
is thrown during the write.
object
- The QuickSerializable
object to write.filename
- The name of the file into which to write.append
- Whether to write the object to the end of the file
IOException
- if an I/O error occurs.public static void write(QuickSerializable object, RandomAccessFile file, long pos) throws IOException
IOException
public static QuickSerializable read(InputStream in) throws IOException, QSException
QuickSerializable
stored in the specified
InputStream
.
in
- The InputStream
from which to read.
QuickSerializable
read.
IOException
- if an I/O error occurs.
QSException
- if in
did not contain a valid
QuickSerializable
object.public static QuickSerializable read(RandomAccessFile file, long pos) throws IOException, QSException
QuickSerializable
stored in the specified
RandomAccessFile
.
file
- The RandomAccessFile
from which to read.pos
- amount to seek to
QuickSerializable
read.
IOException
- if an I/O error occurs.
QSException
- if in
did not contain a valid
QuickSerializable
object.public static void delete(RandomAccessFile file, long pos) throws IOException
pos
- amount to seek to
IOException
public static QuickSerializable read(String filename) throws IOException, QSException
QuickSerializable
stored in the named file.
filename
- The name of the file from which to read.
QuickSerializable
read.
IOException
- if an I/O error occurs.
QSException
- if in
did not contain a valid
QuickSerializable
object.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |