Posted By:
Aleksey_Skorokhodov
Posted On:
Wednesday, March 6, 2002 02:10 AM
I have found some info about saving a message in your FAQ. One point is not clear for me in this answer. Would you please clarify it? the topic is [briefly]: --------------- How can I serialize a JavaMail Message? Author John Zukowski Created Mar 6, 2001 Save the contents to an RFC 822 formatted stream (message.writeTo()), serialize the bytes, and recreate the message at the other end. ----------------- my question - how to "recreate the message"? I have written the byte[] array to disk using the code below. What should I do to "reconstruct" the Message class from byte[] array? ByteArrayOutputStream ba
More>>
I have found some info about saving a message in your FAQ. One point is not clear for me in this answer. Would you please clarify it?
the topic is [briefly]:
---------------
How can I serialize a JavaMail Message?
Author John Zukowski
Created Mar 6, 2001
Save the contents to an RFC 822 formatted stream (message.writeTo()),
serialize the bytes, and recreate the message at the other end.
-----------------
my question - how to "recreate the message"? I have written the byte[] array to disk using the code below. What should I do to "reconstruct" the Message class from byte[] array?
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
InputStream ins = message.getInputStream();
int bytes_read = 0;
// check that we can actually read
byte data[] = new byte[1024];
while ((bytes_read = ins.read(data)) >0) {
baos.write(data, 0, bytes_read);
}
ins.close();
} catch (Exception e) {
System.err.println(LOG_PREFIX + "convertMessage(): " + e);
}
// convert the buffer into a string
return baos.toByteArray();
<<Less