receive message from mobile to java program

receive message from mobile to java program

i got a code to receive message....but wen i receive it its showing a string which is not readable... if possible please edit dis code to retreive the origianl string message.... here is the code import java.io.*; import java.util.*; import javax.comm.*;

public class SimpleRead implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static Enumeration portList;

InputStream inputStream;
SerialPort serialPort;
Thread readThread;

public static void main(String[] args) {
    portList = CommPortIdentifier.getPortIdentifiers();

    while (portList.hasMoreElements()) {
        portId = (CommPortIdentifier) portList.nextElement();
        if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
             if (portId.getName().equals("COM3")) {
        //                if (portId.getName().equals("/dev/term/a")) {
                SimpleRead reader = new SimpleRead();
            }
        }
    }
}

public SimpleRead() {
    try {
        serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
    } catch (PortInUseException e) {System.out.println(e);}
    try {
        inputStream = serialPort.getInputStream();
    } catch (IOException e) {System.out.println(e);}
try {
        serialPort.addEventListener(this);
} catch (TooManyListenersException e) {System.out.println(e);}
    serialPort.notifyOnDataAvailable(true);
    try {
        serialPort.setSerialPortParams(9600,
            SerialPort.DATABITS_8,
            SerialPort.STOPBITS_1,
            SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {System.out.println(e);}
    readThread = new Thread(this);
    readThread.start();
}

public void run() {
    try {
        Thread.sleep(20000);
    } catch (InterruptedException e) {System.out.println(e);}
}

public void serialEvent(SerialPortEvent event) {
    switch(event.getEventType()) {
    case SerialPortEvent.BI:
    case SerialPortEvent.OE:
    case SerialPortEvent.FE:
    case SerialPortEvent.PE:
    case SerialPortEvent.CD:
    case SerialPortEvent.CTS:
    case SerialPortEvent.DSR:
    case SerialPortEvent.RI:
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
        break;
    case SerialPortEvent.DATA_AVAILABLE:
        byte[] readBuffer = new byte[20];

        try {
            while (inputStream.available() > 0) {
                int numBytes = inputStream.read(readBuffer);
            }
            System.out.print(new String(readBuffer));
        } catch (IOException e) {System.out.println(e);}
        break;
    }
}

}

View Answers









Related Tutorials/Questions & Answers:
receive message from mobile to java program
receive message from mobile to java program  i got a code to receive message....but wen i receive it its showing a string which is not readable... if possible please edit dis code to retreive the origianl string message.... here
java program to exchange soap message
that how can I write the server side program in order to receive the message...java program to exchange soap message  Hi Friends, I want... a set of 15 parameters and program on web server side receives this 15 parameters
Advertisements
receive a ResultSet from a stored procedure
receive a ResultSet from a stored procedure  How do I receive a ResultSet from a stored procedure
Sending and receiving xml message using Java Program
Sending and receiving xml message using Java Program  Hi Friends, I want to send and receive xml files between two java programs using wire format... sample program to understand. Thanks in advance. Regards, Atul Patil
Sending and receiving xml message using Java Program
Sending and receiving xml message using Java Program  Hi Friends, I want to send and receive xml files between two java programs using wire format... sample program to understand. Thanks in advance. Regards, Lisha Ahuja
how to delete a jar file from mobile by using j2me program.
how to delete a jar file from mobile by using j2me program.  When i'll update a new version jar in mobile. Then i want to delete that old jar which is previously present in mobile. How to do
How to send message in struts on mobile - Struts
How to send message in struts on mobile  Hello Experts, How can i send messages on mobile i am working on strus application and i want to send message from jsp
How to easily send and receive recorders from database (in AJAX)?
How to easily send and receive recorders from database (in AJAX)?   Hi all, I have a question, iam working in JAVA web application and can somebody please explain or give me an example how to send and receive recorders from
send sms from pc to mobile via gsm modem in java
..... can u pls help me to retrieve message from mobile to java program... import...send sms from pc to mobile via gsm modem in java  pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
WAS server configuration from JAVA program
WAS server configuration from JAVA program  How to get web sphere server status like heap,connection pool properties,stall counts etc. from a java applciation
send sms from pc to mobile
send sms from pc to mobile  java program to send sms from pc to mobile
sms from pc to mobile
sms from pc to mobile  Sir I am developing a website and i need a code to send sms on any mobile from the wbesite.pls help me. thanx in advance
sms from pc to mobile
sms from pc to mobile  Sir I am developing a website and i need a code to send sms on any mobile from the wbesite.pls help me. thanx in advance
mobile banking login program
mobile banking login program  static Display dis; static Login destroy; public Login() { dis=Display .get Display(this); } public void startApp() { destroy=this; LoginScreen
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
Compiling and Running Java program from command line
Compiling and Running Java program from command line - Video tutorial that explains you all steps necessary to compile and run the Java program from dos... of compiling and running java program from command line. We have also video
Opening a browser only with body from a java program
Opening a browser only with body from a java program  Hi all, I got... { //attempt to use Desktop library from JDK 1.6+ Class<?> d = Class.forName...; Have a look at the following link: http://www.roseindia.net/tutorial/java
send sms from pc to mobile via gsm modem connected to pc in java
send sms from pc to mobile via gsm modem connected to pc in java  pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
how to delete a jar from mobile
how to delete a jar from mobile  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me the code how to do
Getting and sending data to and from mobile and the system
Getting and sending data to and from mobile and the system  Hi, For getting and sending data to mobile from system.make system is a server.From mobile send a request to the server and get response.Then process the response
Java Message Services - JMS
Java Message Services  What is Java Message Services
Write a program to display grade message according to the marks
Write a program to display grade message according to the marks  pls give d answer how to Write a program to display grade message according to the marks     Write a program to display grade message according
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
Connect a linux machine from linux using java program without password
Connect a linux machine from linux using java program without password  Connect a linux machine from linux using java program without password. Can anyone help me
java program to read multiple files from a directory and display them on a jframe
java program to read multiple files from a directory and display them on a jframe  hi guys i want to write a java program that will read all files in a directory and display them one by on on a jframe on jpanel with specific key
how to write to java program to get the particular data from the website
how to write to java program to get the particular data from the website   i have to get the particular data by selecting the just numbers.. from the site .. how to get the ful details from the website by clicking the number
how to execute a unix shell script from a java program
the script name from a java code .once you execute this java program...how to execute a unix shell script from a java program  well , i am facing this problem.. i have tried a few sample codes but there isn't any
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me
how to delete a jar from mobile in j2me application
how to delete a jar from mobile in j2me application  After auto updating a new version of jar from server. I want to delete the old jar from mobile and want to install the new jar which is present in server. Can u tell me

Ads