GeeCON Prague 2014*
The moose likes JDBC 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
Bookmark "length of input stream" Watch "length of input stream" New topic
Author

length of input stream

Madhuri Abhi
Greenhorn

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

Joined: Oct 14, 2005
Posts: 18570
    
    8

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
Greenhorn

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
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

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.


[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
 
GeeCON Prague 2014
 
subject: length of input stream