Skip to content

Practice 02 Loading Binary Files

squid233 edited this page Jan 3, 2025 · 5 revisions

We can load binary files into MemorySegment and manage them with Arena.

See IOUtil.java for more infomation.

Example

try (var is = ClassLoader.getSystemResourceAsStream("path")) {
    var seg = arena.allocateFrom(JAVA_BYTE, is.readAllBytes());
    // use the data...
}
Clone this wiki locally