Code example for ByteArrayOutputStream

Methods: toByteArray, write

0
 */ 
public abstract class AbstractLogWriter implements LogWriter { 
    @Override 
    public final void writeRecord(LogRecord entry) throws LogException {
        ByteArrayOutputStream gather = new ByteArrayOutputStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try { 
            entry.write(gather);
            byte[] data = gather.toByteArray();
            writeInt32(entry.getRecordType().getID(), out);
            writeInt32(data.length, out);
            out.write(data);
            write(out.toByteArray());
        } 
        catch (IOException e) {
            throw new LogException(e);
        } 
    } 
 
    /** 
       Write a set of bytes to the log.