clojure.core/byte-array¶
Creates an array of bytes
Examples¶
Note by dspearson¶
The maximum size of a byte-array is Integer/MAX_VALUE, as arrays are int-indexed in Java. However, it is possible to pass a value that is larger than this, resulting in a cast that will wrap around. This incorrect usage will not give any indication of error.
Note by luposlip¶
To type hint a byte array, use this non-obvious syntax:
(.write ^OutputStream output-stream ^"[B" bytearray)
Note by brunchboy¶
You can also use ^bytes to type hint a byte array, and as of Clojure 1.12, ^byte/1 for a one-dimensional byte array, ^byte/2 for two dimensions, etc.
See also¶
- clojure.core/bytes (0)
- clojure.core/byte (0)
Content from the matching ClojureDocs page, with authors credited on each contribution.