byte[] -> TObject  
Author Message
Mike Shultz





PostPosted: 2003-10-3 18:11:00 Top

java-programmer, byte[] -> TObject
Function is receiving TObject as argument, but I have byte[], so I need something like this:


somefunc(new String(abc.getBytes()));

getBytes() returns byte[]. Is there some other class that would take byte[] in constructor? Something like: new Bytes(byte[]),
because I can't use String class.

Original code:

MimeBodyPart attachment = new MimeBodyPart();
attachement.setContent(abc.getBytes(), contentType);


 
Mike Shultz





PostPosted: 2003-10-3 20:00:00 Top

java-programmer >> byte[] -> TObject
Thank you. I wrote this:

attachFile.setContent(new ObjectInputStream(new ByteArrayInputStream(abc.getBytes())).readObject(), contentType);

but, got an exception:

java.io.StreamCorruptedException: invalid stream header...


 
Mike Shultz





PostPosted: 2003-10-3 20:05:00 Top

java-programmer >> byte[] -> TObject
All I'm trying to do is to set attachmenet in my mail. It is very easy if you are setting text:

attachement.setText("Some text here...");

but, how can I add en .exe file as attachement? I need to use setContent(TObject o, String contentType). I need to pass bytes
( byte[] ) to setContent() function.