jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Bocanegra" <tobias.bocane...@day.com>
Subject Re: Pulling binary data from a property
Date Wed, 11 Oct 2006 14:33:15 GMT
just a guess: try read/write via a buffer and not byte-per-byte ?
maybe theres something wrong in the read() implementation of the
respective inputstream.

regards, toby

On 10/11/06, Shane Preater <shane.preater@googlemail.com> wrote:
> Hi,
>
> I have a property on a node called 'blobData' this property has been loaded
> using the following snippet:
>
> ValueFactory factory = session.getValueFactory();
> Value value = factory.createValue(new ByteArrayInputStream(data));
> node.setProperty(propertyName, value);
>
> Then obviously further on a call to session.save(); is used to persist this.
>
> I am now trying to get this binary information back from the property using:
>
> InputStream inputStream = node.getProperty(property)
>                             .getStream();
> int readInt = 0;
> while ((readInt = inputStream.read()) >= 0) {
>   outputStream.write(readInt);
>  }
> return outputStream.toByteArray();
>
> However this always returns an empty byte array as the first call to
> inputStream.read() returns -1 indicating the end of the stream.
>
> Could someone point me in the direction of my error.
>
> Thanks,
> Shane.
>
>


-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Mime
View raw message