PUBLIC OBJECT

10 things you can do with Okio's ByteString

    // Decode base64.
    ByteString a = ByteString.decodeBase64("bWFwbGUgc3lydXA=");

    // Encode base64.
    String b = a.base64();

    // Decode hex.
    ByteString c = ByteString.decodeHex("776166666c6573");

    // Encode hex.
    String d = c.hex();

    // Read from an input stream.
    ByteString e = ByteString.read(new FileInputStream("foo.txt"), 50);

    // Write to an output stream.
    a.write(new FileOutputStream("bar.bin"));

    // Encode UTF-8.
    ByteString f = ByteString.encodeUtf8("petit déjeuner");

    // Decode UTF-8.
    String g = a.utf8();

    // Use a byte string as a Map key (uses equals() and hashCode().)
    Map<ByteString, String> map = new LinkedHashMap<>();
    map.put(a, "decoded base64");
    map.put(c, "decoded hex");
    map.put(e, "read an input stream");

    // Copy the bytes into an array.
    byte[] h = a.toByteArray();

The entire jar is less than 100 KiB so you shouldn't hesitate to include it wherever you need it.

Get Okio on GitHub.