Module resource as seekable byte channel?
Alan Bateman
Alan.Bateman at oracle.com
Sun Feb 4 20:41:48 UTC 2018
On 04/02/2018 13:31, Mark Raynsford wrote:
> Hello.
>
> I'm working on a problem that would seem to require accessing a
> (large) resource included inside a module in random manner. More
> specifically, I have some large audio resources inside a module and
> need to be able to get something analogous to a SeekableByteChannel
> for a given resource so that I can stream the audio and seek
> forwards/backwards.
>
> I could unpack the resources to the filesystem, but I'd prefer not to
> do this (because that would then mean I'm using double the amount of
> storage).
>
> Is there some way to get access to a module resource as a
> SeekableByteChannel in the standard library?
>
The only support for random access is in the ModuleReader API where the
read method returns a ByteBuffer containing the resource. This is very
efficient for resources in modules that are linked into the runtime
image as it's essentially a slice of a memory mapped region. It's not
efficient for modules that are packaged as JAR files as random access
poses challenges there (esp. when entries in JAR file are compressed).
-Alan
More information about the jigsaw-dev
mailing list