Ejemplo n.º 1
0
  public void testWrite2() throws IOException {
    FileOutputStream fos = new FileOutputStream("test.cbor");
    Output output = new StreamOutput(fos);
    CborWriter writer = new CborWriter(output);

    Map<String, String> someMap = new HashMap<String, String>();
    someMap.put("hello", "world");
    someMap.put("one", "two");
    someMap.put("test", "catch");

    writer.write(someMap);

    output.close();
  }
Ejemplo n.º 2
0
  public void testWrite() throws IOException {
    FileOutputStream fos = new FileOutputStream("test.cbor");
    Output output = new StreamOutput(fos);
    CborWriter writer = new CborWriter(output);

    writer.writeMap(2);

    // key 1
    writer.writeString("hello");
    // value 1
    writer.writeInt(
        new BigInteger(
            "5126378562348346534857632482374652582763453486542735654325645832478457363787456436263574"));

    // key 2
    writer.writeString("world");
    // value 2
    writer.writeArray(1);
    writer.writeString("hihihi");

    output.close();
  }