I am using readmessages.java example.
I would like to make an internet connection to save a sms but the
internal "process" method does not work. If I feel in the main is
correct ... strange.
FROM MAIN:
public static void main(String args[])
{
System.out.println("Connection.");
String inputLine = "";
try {
URL url = new URL("http://www.google.it");
try {
URLConnection connection = url.openConnection();
connection.setDoOutput(false);
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
inputLine = in.readLine();
in.close();
} catch (IOException ex) {
System.out.println("IO Error " + ex);
}
} catch (MalformedURLException ex) {
System.out.println("IO Error " + ex);
}
System.out.println(inputLine);
System.out.println("End connection.");
ReadMessages app = new ReadMessages();.....
...
:
--------------------------------------------
OUTPUT
---------------------------------------------
Connection.
<!doctype html><html><head><meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1"><title>Google</
title><sc.......
End connection.
Example: Read messages from a serial gsm modem.
SMSLib: A Java API library for sending and receiving SMS via a GSM
modem or other supported gateways.
This software is distrib...
...
--------------------------------------------- (OK)
FROM method process()
public void process(String gatewayId, MessageTypes msgType,
InboundMessage msg)
{
if (msgType == MessageTypes.INBOUND) System.out.println(">>> New
Inbound message detected from Gateway: " + gatewayId);
else if (msgType == MessageTypes.STATUSREPORT)
System.out.println(">>> New Inbound Status Report message detected
from Gateway: " + gatewayId);
System.out.println("Connection...");
String inputLine = "";
try {
URL url = new URL("http://www.google.it");
try {
URLConnection connectioni = url.openConnection();
connectioni.setDoOutput(false);
BufferedReader in = new BufferedReader(new
InputStreamReader(connectioni.getInputStream()));
inputLine = in.readLine();
in.close();
} catch (IOException ex) {
System.out.println("IO Error " + ex);
}
} catch (MalformedURLException ex) {
System.out.println("IO Error " + ex);
}
System.out.println(inputLine);
System.out.println("End connection...");
.....
:
--------------------------------------------
OUTPUT
---------------------------------------------
....
New Inbound message detected from Gateway: modem.com1
Connection...
---------------------------------------------
In particular, the method process to exit here
BufferedReader in = new BufferedReader (new InputStreamReader
(connectioni.getInputStream ()));
Is not it strange?
I tried using a class thred for external connection but I get the same
result.
Someone knows a solution?
--
You received this message because you are subscribed to the Google Groups
"SMSLib User Group" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/smslib?hl=en.