How to get FileChannel from resource
Ulf Zibis
Ulf.Zibis at gmx.de
Mon Mar 2 14:11:51 UTC 2009
Am 02.03.2009 14:13, Tom Hawtin schrieb:
> 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 naked files.
>
> For jared resources, you can cast the URLConnection to
> JarURLConnection and call getJarFile. Some implementations of
> JarURLConnection may not return a JarFile.
>
> Tom Hawtin
Tom, thanks for your hint.
Ii unfortunately wouldn't help to solve my current problem, because
JarFile either doesn't provide getChannel().
... But it would help to simplify my other problem from thread:
"How to get list of classes from a package" from 2009-02-16
Anyway, don't you think, there should be something like
getResourceAsChannel() ?
-Ulf
More information about the core-libs-dev
mailing list