How to get FileChannel from resource
Thomas.Hawtin at Sun.COM
Mon Mar 2 13:13:36 UTC 2009
Ulf Zibis wrote:
> Anyway, I'm looking for a DirectBuffer directly from a resource file.
> So I think there is something missing:
> URL.openChannel() or Class#getResourceAsChannel()
> Maybe there is a way to get a RamdomAccessFile from URL to get the
> Channel from. Anybody knows ?
If it's a file URL, then obviously you can check the protocol and create
a `File` from the file portion. However most resources are not stored in
For jared resources, you can cast the URLConnection to JarURLConnection
and call getJarFile. Some implementations of JarURLConnection may not
return a JarFile.
More information about the core-libs-dev