Skip to content
stuarthalloway edited this page Nov 20, 2012 · 2 revisions

The key interfaces in everyday usage are Reader and Writer, which wrap arbitrary streams. The following example writes data to a byte array, and then reads it back.

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer w = new FressianWriter(baos);
w.writeObject(bunchOfData());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
Reader r = new FressianReader(bais);
Object result = r.readObject());

Fressian has a rich set of built-in data types, so the bunchOfData can contain a wide variety of things.

    public static Set bunchOfData() {
        Date now = new Date();
        UUID unique = UUID.randomUUID();
        BigInteger big = new BigInteger("9999999999999999999999999999999");
        Set s = set(1, false, "hello", now, unique, big);
        return s;
    }

You can see the complete example here.

Clone this wiki locally