Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get first bytes value from an InputStream?

807606May 23 2007 — edited May 23 2007
Hello,

I'm scanning a database for pictures and retreive them through a call to ResultSet.getBinaryStream(1) that gives me an InputStream.

I would like to scan the first 2 bytes to know if the returned stream is a JPEG picture (first 2 bytes must be 0xFF and 0xD8).

I can see them in the protected "buf" member of InputStream in the debugger but how can I access them through the code?

Is there a way to convert the InputStream into a byte array?

Regards,
Lara.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2007
Added on May 23 2007
10 comments
1,169 views