ShortFileAttributeAccessor (@NotNull FSRecordsImpl vfs, @NotNull FileAttribute attribute) { return new ShortFileAttributeAccessor() { @Override public short read(int fileId, short defaultValue) { Short value = vfs.readAttributeRaw(fileId, attribute, buffer -> { //stream.writeShort() writes in BIG_ENDIAN (default byte order for JVM) return buffer.order(BIG_ENDIAN).getShort(); }); return value == null ? defaultValue : value.shortValue(); } @Override public void write(int fileId, short value) throws IOException { try (var stream = vfs.writeAttribute(fileId, attribute)) { stream.writeShort(value); } } }; }