public ZMsg dump(Appendable out)
    {
        try {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            pw.printf("--------------------------------------\n");
            for (ZFrame frame : frames) {
                pw.printf("[%03d] %s\n", frame.size(), frame);
            }
            out.append(sw.getBuffer());
            sw.close();
        }
        catch (IOException e) {
            throw new RuntimeException("Message dump exception " + super.toString(), e);
        }
        return this;
    }
@Test
    public void testDump()
    {
        ZMsg msg = new ZMsg().append(new byte[0]).append(new byte[] { (byte) 0xAA });
        msg.dump();

        StringBuilder out = new StringBuilder();
        msg.dump(out);

        System.out.println(msg);

        assertThat(out.toString(), endsWith("[000] \n[001] AA\n"));
    }