File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 19693

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: 32320

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: length of input stream
It's not a secret anymore!