Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes length of input stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "length of input stream" Watch "length of input stream" New topic

length of input stream

Madhuri Abhi

Joined: Jun 29, 2011
Posts: 11
How can i know the length of an input stream?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Generally, you can't. That's because an InputStream might eventually return data which doesn't even exist at the time you ask that question.

But why is this a JDBC question?
Madhuri Abhi

Joined: Jun 29, 2011
Posts: 11
I am sorry that i have posted this question in a wrong group. this is a simple java question.

I have an image in database which is actually in the form of hexa decimal. I am getting it as binary stream and converting it to bye array and finally into an iamge. I would like to calculate the size of the image.

Since i use Derby database, I cant use

Please help
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

THis is a database question since it deals with reading an image from the database. You are on the right place. Storing an image in hex is a problem. It should be stored in binary/BLOB format.

When you call rs.getBlob(), there is a method to get the length. Not sure if this would work with CLOB or if it corrupts the file.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: length of input stream
It's not a secret anymore!