我正在尝试将InputStream
转换为SeekableByteChannel
,以便使用LWJGL在Open AL中进行流式传输。
借助在线演示的帮助,目前的代码如下:
InputStream source = Thread.currentThread().
getContextClassLoader().
getResourceAsStream(resource);
ReadableByteChannel rbc = Channels.newChannel(source);
但我不确定,如果可能的话,我如何通过OGG文件进行搜索,以便在不将其转换为SeekableByteChannel
的情况下进行流式传输
如果需要,我很乐意提供更多代码,并感谢您提前提供任何帮助
答案 0 :(得分:1)
看看apache commons compress库,您可以从字节数组构造SeekableInMemoryByteChannel
。并将InputStream
转换为字节数组也很容易。
InputStream inputStream; // input stream
SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel
(IOUtils.toByteArray(inputStream));