Subject RE: [Firebird-Java] Re: OT - Stream Question
Author Robert DiFalco
Unfortunately a ByteArrayOutputStream will STILL reallocate and copy
over the byte array each time you call "toByteArray" (which I mistakenly
called "getBytes"), so I would still have a lot of unecessary overhead.

I could add a method to return a reference to "buf" in the
ByteArrayOutputStream but the problem there is that "buf" will probably
be the wrong size and "setBytes" does not take an offset and length.

So far, it seems like adding an "asInputStream" method to a
ByteArrayOutputStream subclass is still much more memory and processor
efficient. I just wish there was a way to do it with the standard Java
classes.

R.


-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Wednesday, June 11, 2003 12:50 PM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] Re: OT - Stream Question


> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> someObject.write( baos );
>
> statement.setBinaryStream( COLUMN_BLOB, new ByteArrayInputStream(
> baos.getBytes() ) );

What prevents from you from setting byte array instead of stream?

statement.setBytes(COLUMN_BLOB, baos.getBytes());

Roman


Yahoo! Groups Sponsor





To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.