public void sendSMS(final String phoneNumber, final String message) throws IOException{
String address = "sms://" + phoneNumber + ":5000";
MessageConnection con = null;
try {
con = (MessageConnection) Connector.open(address);
TextMessage txtmessage =
(TextMessage) con.newMessage(MessageConnection.TEXT_MESSAGE);
txtmessage.setAddress(address);
txtmessage.setPayloadText(message);
con.send(txtmessage);
} catch (Exception e) {
throw new IOException("failed to send sms " + e.getMessage());
} finally {
if (con != null) {
try {
con.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
}