Bytes
Construction
// from a raw byte array
Bytes b = Bytes.from(new byte[]{0, 1, 2});
// from UTF-8 text
Bytes b = Bytes.from("Hello");
// from text with an explicit charset
Bytes b = Bytes.from("Hello", ISO_8859_1);
// by decoding a HEX-encoded string
Bytes b = Bytes.from("cafebabe", HEX);
// by decoding a BASE64-encoded string
Bytes b = Bytes.from("c2lnbg==", BASE64);
// from a file's full contents
Bytes b = Bytes.from(Path.of("secret.bin"));
Bytes b = Bytes.from(new File("secret.bin"));
// from an input stream
Bytes b = Bytes.from(inputStream);
// by decoding a PEM-encoded string
Bytes b = Bytes.fromPem("-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----");Consumption
Equality
Why Bytes?
Last updated
Was this helpful?