Yet another library for encoding and decoding data in b-encode format. The format is described here
Entries are defined by interface Entry and represent b-encode format entity. Entries can be created using EntryFactory interface.
EntryFactory entryFactory = new EntryFactoryImpl()
StringEntry strEntry = entryFactory.createStringEntry("sampleStringEntry");
IntegerEntry intEntry = entryFactory.createIntegerEntry(42);
ListEntry listEntry = entryFactory.createListEntry(strEntry, intEntry);
// create map first
Map<StringEntry,Entry> map = new HashMap<>();
map.put(strEntry, intEntry);
DictionaryEntry dictionary = entryFactory.createDictionaryEntry(map);or using CompositeEntryBuilder for dictionaries and lists
DictionaryEntry entry = dictionary()
.entry("name", "Arthur")
.entry("number", 42L)
.entry("picture", "")
.entry("planets", list("Earth", "Somewhere else", "Old Earth"))
.create();Encoding is done using BEncoder interface. It takes output stream and collection of entries to be encoded.
BEncoder bencoder = new BEncoderImpl();
bencoder.encode(outStream, entriesToEncode);Entries will be written to output stream.
Decoding is done using BDecoder. BDecoder reads data from input stream, creates entries from it, and puts them into a given collection.
BDecoder bdecoder = new BDecoderImpl();
bdecoder.decode(inStream, decodedEntries);