because it can stream: reduces memory usage (don't have to hold file in core), and is faster (can start to send/receive before whole object is created/read).
MIME TYPE:
In any event, Axis 1.3 doesn't handle it, invents its own DataHandler type instead. No good for non-Axis clients.
The Transferable interface, spot the difference:
1.new DataHandler(new String("foo"), "text/csv"))
new DataHandler(new String("foo"), "text/plain"))
This is silly. The client code chooses the object to decode the data handler based on its MIME type, not the type of the object that it was created with. These are both Strings and could be de-serialized in exactly the same way. But noooo, a built-in handler exists for text/plain (String), but not for text/csv.
I ended up using
new DataHandler(new org.apache.commons.mail.ByteArrayDataSource(os.toByteArray(), "text/csv"));
new DataHandler(new String("foo"), "text/plain"))
This is silly. The client code chooses the object to decode the data handler based on its MIME type, not the type of the object that it was created with. These are both Strings and could be de-serialized in exactly the same way. But noooo, a built-in handler exists for text/plain (String), but not for text/csv.
I ended up using
new DataHandler(new org.apache.commons.mail.ByteArrayDataSource(os.toByteArray(), "text/csv"));
even though this doesn't really take advantage of the streaming capability or reduce the memory requirements. Should really make an inputstream out of the outputstream, and stream the stream.
No comments:
Post a Comment