How to get FileChannel from resource (original) (raw)
Ulf Zibis Ulf.Zibis at gmx.de
Mon Mar 2 12:15:30 UTC 2009
- Previous message: How to get FileChannel from resource
- Next message: How to get FileChannel from resource
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sherman, yes, you are right. That's not what I'm looking for.
This would be slower, than reading the stream directly, because the underlying byte array will be copied 2 times by BufferedInputStream# + Channels.ReadableByteChannelImpl#read(), ... but maybe not, because looping BufferedInputStream#readChar() could be slower than twice System.arraycopy().
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 ?
Should I file a bug ? Somebody any objections ?
-Ulf
Am 02.03.2009 08:50, Xueming Shen schrieb:
You can use java.nio.channels.Channels.newChannel() to get a ReadableByteChannel on top of the InputStream you get from URL.openStream()...
but if my guess of what you want to do is correct, that channel is probably not that useful:-) Sherman Ulf Zibis wrote: Hi all
there is a { URL getResource(String name) } in class Class. Does anybody know, how to get a java.nio.channels.Channel or FileChannel from this URL? Thanks in advance, -Ulf
- Previous message: How to get FileChannel from resource
- Next message: How to get FileChannel from resource
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]