10-30-2007, 10:21 AM
|
#1 (permalink)
|
| Thumbs Must Hurt
Join Date: Jun 2007 Model: 8100 PIN: N/A Carrier: movistar
Posts: 51
Post Thanks: 0 Thanked 0 Times in 0 Posts
| ClassCastException Please Login to Remove! I have a application to send a mail whit a file attachment and request any error java.lang.ClassCastException in the line of code AttachmentHandlerManager.
help me whats is the problem whit me file?.
//////
Object obj = filetoattach();
AttachmentHandlerManager.getInstance().addAttachme ntHandler(AttachmentHandler) obj);
Transport.send(msg);
///////
private Object filetoattach() {
Object o = null;
try {
FileConnection fconn = (FileConnection)Connector.open("file:///store/samples/pictures/orbital.jpg");
// If no exception is thrown, then the URI is valid, but the file may or may not exist.
if (fconn.exists()) {
System.out.println("Existe el Archivo");
InputStream input = null;
input = fconn.openInputStream();
int available = 0;
available = input.available();
byte[] data = new byte[available];
input.read(data, 0, available);
o = (Object) input;
}
}
catch (Exception ioe) {
System.out.println("ERROR : " + ioe);
}
return o;
} |
| Offline
| |