List of usage examples for com.fasterxml.jackson.dataformat.cbor CBORFactory CBORFactory
public CBORFactory()
From source file:org.apache.nutch.tools.CommonCrawlDataDumper.java
private byte[] serializeCBORData(String jsonData) { CBORFactory factory = new CBORFactory(); CBORGenerator generator = null;/*ww w . j a v a 2 s.co m*/ ByteArrayOutputStream stream = null; try { stream = new ByteArrayOutputStream(); generator = factory.createGenerator(stream); // Writes CBOR tag writeMagicHeader(generator); generator.writeString(jsonData); generator.flush(); stream.flush(); return stream.toByteArray(); } catch (Exception e) { LOG.warn("CBOR encoding failed: " + e.getMessage()); } finally { try { generator.close(); stream.close(); } catch (IOException e) { // nothing to do } } return null; }