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, writeBytes
public 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.IOException
startRecord()
,
restartRecord(int)
,
endRecord()
public void startRecord() throws IOException
IOException
restartRecord(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.IOException
startRecord()
,
startRecord(int)
,
endRecord()
public void endRecord() throws IOException
IOException
startRecord()
,
restartRecord(int)
,
startRecord(int)
public int readBytes(byte[] buf, int start, int count) throws IOException
Stream
readBytes
in class Stream
buf
- the byte array to read data intostart
- the start position in the arraycount
- the number of bytes to readIOException
public int writeBytes(byte[] buf, int start, int count) throws IOException
Stream
IOException
if an error prevented the write
operation from occurring.writeBytes
in class Stream
buf
- the byte array to write data fromstart
- the start position in the byte arraycount
- the number of bytes to writeIOException
public void close() throws IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
IOException
public Stream getStream()
protected void finalize()
finalize
in class java.lang.Object