BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 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
Default 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  
Old 10-30-2007, 10:48 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you try to cast your filetoattach-object to AttachmentHandler which is not possible.

take a look at p. 181ff of the BlackBerry_Java_Development_Environment_Developmen t_Guide.pdf
Sending a mail with an attachment is explained there.

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LOT OF 2 INTEL XEON SLACB CPU/MICROPROCESSORS E5310
$19.99
LOT OF 2 INTEL XEON SLACB CPU/MICROPROCESSORS E5310 pictureDELL PRECISION 490 WORKSTATION XEON 5160 3GHZ/8GB/QUADRO FX/XPPRO COA
$149.99
DELL PRECISION 490 WORKSTATION XEON 5160 3GHZ/8GB/QUADRO FX/XPPRO COA pictureQty 2 Dell Poweredge 1950 Servers w/ Nortel CCMS CCMA Contact Center Management
$1199.0
Qty 2 Dell Poweredge 1950 Servers w/ Nortel CCMS CCMA Contact Center Management pictureScriptPro Pharmacy Automation SP Central Expander Server Xeon E5430, 36GB RAM
$199.95
ScriptPro Pharmacy Automation SP Central Expander Server Xeon E5430, 36GB RAM pictureRofin Polilight PL500 Forensic Light 500W Xeon UV Lamp 50-60Hz PL 500 *WORKING*
$6999.99
Rofin Polilight PL500 Forensic Light 500W Xeon UV Lamp 50-60Hz PL 500 *WORKING* picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.