The moose likes JDBC and Relational Databases and the fly likes reading Blob without knowing the filename Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "reading Blob without knowing the filename" Watch "reading Blob without knowing the filename" New topic

reading Blob without knowing the filename

Janine Guenther

Joined: Aug 30, 2002
Posts: 3
i try to read a Blob, but i don't know the filename of it.
In all examles i found, there is an FileOutputStream(filePath). In the database ist no field for the filename only a field for the Blob.
I know, if i would save a blob into a database, oracle is saving the filename as an attribute/param in this blob-field. How can i read this attribute/param?
in = blob.getBinaryStream();
String filePath = absPath + fileName;
out = new FileOutputStream(filePath);
int bufferSize = blob.getBufferSize();
byte[] buffer = new byte[bufferSize];
int bytesRead = 0;
while ((bytesRead = != -1)
out.write(buffer, 0, bytesRead);
Veena Rani
Ranch Hand

Joined: Mar 09, 2000
Posts: 34
out = new FileOutputStream(filePath);
The filePath is the path of the file on your local machine where you want to save file read from the blob column in the database.
I agree. Here's the link:
subject: reading Blob without knowing the filename
It's not a secret anymore!