dcsimg
writeTo works in a wrong way. why?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Yuan_Tao
Posted On:   Tuesday, March 25, 2003 10:33 AM

I am new to JavaMail. I am writing a provider for Lotus Domino. I compose a MimeMessage, then use the writeTo() method. such Exception is thrown out: java.io.IOException: The system cannot find the path specified at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:161) at javax.activation.DataHandler.writeTo(DataHandler.java:289) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089) ........... at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1503) I don`not know why It always uses the FileInputStream? I composed MimeMessage in the way below. DominoAttachment atta   More>>

I am new to JavaMail. I am writing a provider for Lotus Domino. I compose a MimeMessage, then use the writeTo()
method. such Exception is thrown out:

			
java.io.IOException: The system cannot find the path specified
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:161)
at javax.activation.DataHandler.writeTo(DataHandler.java:289)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
...........
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1503)


I don`not know why It always uses the FileInputStream?
I composed MimeMessage in the way below.

			
DominoAttachment attachment = (DominoAttachment) attachments.get(i);
bodyPart = new MimeBodyPart();
InputStreamDataSource dataSource = new InputStreamDataSource(attachment.getInputStream(), "image/gif");
bodyPart.setDataHandler(new DataHandler(dataSource));
multipart.addBodyPart(bodyPart);


InputStreamDataSource is a subclass of DataSource
			
public class InputStreamDataSource implements DataSource {
private InputStream is = null;
private String contentType = "";
public InputStreamDataSource(InputStream is, String contentType) {
this.is = is;
this.contentType = contentType;
}
public String getName() {
return "";
}
public String getContentType() {
return contentType;
}
public InputStream getInputStream() {
return is;
}
public OutputStream getOutputStream() {
return System.out;
}
}


			
I suppose that the data should be read from InputStreamDataSource.getInputStream()

but In the Exception stack, It shows
java.io.FileInputStream.read called

what is the problem?? I am lost.
Thanks a lot in advance.
   <<Less
About | Sitemap | Contact