commit | 70c96bff395c005b0c3e47240533dcd5d2c56960 | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Fri Jun 04 03:02:37 2021 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Fri Jun 04 03:02:37 2021 +0000 |
tree | 093e7f4e8b99e937aada1dad8d1512cbd6b3b9f3 | |
parent | 987e1c9cd2f5d05b0e538c57bca6381d57919ced [diff] | |
parent | 6b4b6adc5ff8f91e2ddef14adf510e14aaf90204 [diff] |
Snap for 7422738 from 6b4b6adc5ff8f91e2ddef14adf510e14aaf90204 to tm-release Change-Id: I371944abf875efce85f13707e795ce497a56187c
A Java 7 implementation of RFC 7049: Concise Binary Object Representation (CBOR)
Add this to the dependencies section of your pom.xml file:
<dependency> <groupId>co.nstant.in</groupId> <artifactId>cbor</artifactId> <version>0.8</version> </dependency>
ByteArrayOutputStream baos = new ByteArrayOutputStream(); new CborEncoder(baos).encode(new CborBuilder() .add("text") // add string .add(1234) // add integer .add(new byte[] { 0x10 }) // add byte array .addArray() // add array .add(1) .add("text") .end() .build()); byte[] encodedBytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes); List<DataItem> dataItems = new CborDecoder(bais).decode(); for(DataItem dataItem : dataItems) { // process data item }
ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes); new CborDecoder(bais).decode(new DataItemListener() { @Override public void onDataItem(DataItem dataItem) { // process data item } });
This project uses the C4 process for all code changes.
Copyright 2013-2017 Constantin Rack Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.