@Override @SuppressWarnings("unchecked") public synchronized void write(ArchivePacket packet) throws IOException { if (!isOpen()) { throw new IOException("not open"); } if (out == null) { throw new IOException("no output stream found"); } if (packet == null || packet.payload() == null) { throw new IOException("no payload to write for entry"); } byte[] buf = packet.payload().toString().getBytes(); String name = ArchiveUtils.encodeArchiveEntryName(packet); ArchiveEntry entry = out.newArchiveEntry(); entry.setName(name); entry.setLastModified(new Date()); entry.setEntrySize(buf.length); out.putArchiveEntry(entry); out.write(buf); out.closeArchiveEntry(); packetCounter++; if (watcher.getBytesToTransfer() != 0 && watcher.getBytesTransferred() > watcher.getBytesToTransfer()) { logger.debug( "bytes watcher: transferred = {}, rate {}", watcher.getBytesTransferred(), watcher.getRecentByteRatePerSecond()); switchToNextArchive(); watcher.resetWatcher(); } }