You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Fengyun RAO <ra...@gmail.com> on 2014/04/30 07:43:58 UTC

How to deserialize java resource file in the jar package?

In C# version, there is an API:
 IFileReader<T> OpenReader(Stream inStream)
which require only a "Stream" object.

However in java version, it requires a "SeekableInput":
FileReader<D> openReader(SeekableInput in, DatumReader<D> reader)

Now that the data is in the resource file which is embedded in the jar
package,
we can only get a stream using getResourceAsStream() method,
how can we deserialize the data?

I also wonder why are the APIs different between C# and java version.
Could there also be an API requiring only a Stream object in java, which I
think
would be quite convenient.

Re: How to deserialize java resource file in the jar package?

Posted by Fengyun RAO <ra...@gmail.com>.
Thanks Doug, it works!

2014-05-03 5:35 GMT+08:00 Doug Cutting <cu...@apache.org>:

> On Tue, Apr 29, 2014 at 10:43 PM, Fengyun RAO <ra...@gmail.com>
> wrote:
> > Could there also be an API requiring only a Stream object in java, which
> I
> > think would be quite convenient.
>
> Please see DataFileStream, which can be constructed using an
> InputStream.  This is the base class for DataFileReader.
>
>
> http://avro.apache.org/docs/current/api/java/org/apache/avro/file/DataFileStream.html
>
> Doug
>

Re: How to deserialize java resource file in the jar package?

Posted by Doug Cutting <cu...@apache.org>.
On Tue, Apr 29, 2014 at 10:43 PM, Fengyun RAO <ra...@gmail.com> wrote:
> Could there also be an API requiring only a Stream object in java, which I
> think would be quite convenient.

Please see DataFileStream, which can be constructed using an
InputStream.  This is the base class for DataFileReader.

http://avro.apache.org/docs/current/api/java/org/apache/avro/file/DataFileStream.html

Doug