How to convert an InputStream to a DataHandler?

My approach would be to write a custom class implementing DataSource that wraps your InputStream Then create the DataHandler giving it the created DataSource.

My approach would be to write a custom class implementing DataSource that wraps your InputStream. Then create the DataHandler giving it the created DataSource.

Ah, that's a great idea. I'll try that when I get a chance. – pcorey May 13 '10 at 21:58 I thought the same.

But beware, that then the DataHandler must be used (consume its input), "inside you loop", while the ResultSet is open. For example, you cant probably pass the DataHandler object to an upper layer. – leonbloy May 13 '10 at 22:02 @leonbloy The stated goal was to process the data without copying it from result set.

This implies that the result set must be open the entire time regardless of how you do it. – Kathy Van Stone May 13 '10 at 23:04.

I also ran into this issue. If your source data is a byte axis already has a class that wraps the InputStream and creates a DataHandler object. Here is the code //this constructor takes byte as input ByteArrayDataSource rawData= new ByteArrayDataSource(resultSet.

GetBytes(1)); DataHandler data= new DataHandler(rawData); yourObject. SetData(data); Related imports import javax.activation. DataHandler; import org.apache.axiom.attachments.

ByteArrayDataSource; Hope it helps!

Note that the getInputStream of the DataSource must return a new InputStream everytime called. This means, you need to copy somewhere 1st. For more info, see bugs.sun.com/bugdatabase/view_bug.do?bug....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions