public class ResizeRecord extends Stream
PDBFile pdb = new PDBFile("Name.Crtr.Type",PDBFile.CREATE);
ResizeRecord rs = new ResizeRecord(pdb,512);
DataStream ds = new DataStream(rs);
rs.startRecord();
ds.writeStringArray(aStringArray);
rs.endRecord();
PS: if you dont call startRecord, writeBytes will simply call PDBFile.writeBytes and will not resize the record!skipBuffer| Constructor and Description |
|---|
ResizeRecord(PDBFile cat,
int initialSize)
Constructs the resize stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
closes the PDBFile
|
void |
endRecord()
Must be called after the record is finished so it can be properly resized.
|
protected void |
finalize() |
Stream |
getStream()
Returns the stream attached to this stream (which is always a PDBFile).
|
int |
readBytes(byte[] buf,
int start,
int count)
Reads bytes from the stream.
|
boolean |
restartRecord(int pos)
Restart writing to the given record pos, overwritting the current record.
|
void |
startRecord()
Appends a new record to the PDBFile.
|
void |
startRecord(int pos)
Inserts the record at the specified index in the PDBFile.
|
int |
writeBytes(byte[] buf,
int start,
int count)
Writes bytes to the stream.
|
asInputStream, asOutputStream, asStream, asStream, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytes, writeBytespublic ResizeRecord(PDBFile cat, int initialSize)
cat - The PDBFile associatedinitialSize - The initial size of the record. CANNOT BE 0!public void startRecord(int pos)
throws IOException
pos - The position where to insert the record. If greater or equal to the record count, the record is
appended.IOExceptionstartRecord(),
restartRecord(int),
endRecord()public void startRecord()
throws IOException
IOExceptionrestartRecord(int),
startRecord(int),
endRecord()public boolean restartRecord(int pos)
throws IOException
pos - The position to overwrite. If pos is lower than 0 or greater than the
number of records of the PDBFile, the record is appended.IOExceptionstartRecord(),
startRecord(int),
endRecord()public void endRecord()
throws IOException
IOExceptionstartRecord(),
restartRecord(int),
startRecord(int)public int readBytes(byte[] buf,
int start,
int count)
throws IOException
StreamreadBytes in class Streambuf - the byte array to read data intostart - the start position in the arraycount - the number of bytes to readIOExceptionpublic int writeBytes(byte[] buf,
int start,
int count)
throws IOException
StreamIOException if an error prevented the write
operation from occurring.writeBytes in class Streambuf - the byte array to write data fromstart - the start position in the byte arraycount - the number of bytes to writeIOExceptionpublic void close()
throws IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableIOExceptionpublic Stream getStream()
protected void finalize()
finalize in class java.lang.Object