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!

Not able to write to Blob to a File

Sudipto DesmukhJan 25 2012 — edited Jan 28 2012
Hi All ,
I am using the following code to write to a blob to a file . When I just run the java Class it works fine .
But nothing gets written into the file when this Class is executed from the Server (I am running this as a Oracle ADF Application from the Weblogic Server 10.3.5).
I can see the file getting created but its empty. I also made sure that that file was permissions for all kind of users.
public static int execute(File blobFile, BlobDomain blob)
{

int success = 1;
try
{
FileOutputStream outStream = new FileOutputStream(blobFile);
InputStream inStream = blob.getBinaryStream();
int length = -1;
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
while ((length = inStream.read(buffer)) != -1)
{
System.out.println("^^%^%^ I should write");
outStream.write(buffer, 0, length);
outStream.flush();
}
inStream.close();
outStream.close();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("ERROR(djv_exportBlob) Unable to export:"+blobFile.getName());
success = 0;
}
finally
{
return success;
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2012
Added on Jan 25 2012
17 comments
498 views