blackberry - Read incoming sms without spaces -


The following code reads an incoming SMS, then prints the message body. How do I get an app to print messages without any spaces? For example: Incoming SMS reads "I am here", so "I am here" is printed, but I want the app to print "Iam" here.

How can I do this? Any help would be most appreciated.

This is my code:

  running public zeros () {try {DatagramConnection _dc = (DatagramConnection) Connector.open ("sms: //"); For (;;) {Datagram D = _dc.newDatagram (_dc.getMaximumLength ()); _dc.receive (d); Byte [] bytes = d.getData (); String address = d.getAddress (); String msg = new string (bytes); Println (address); Println (message); }} Hold (exception me) {}}   

thanks

Try it

Add this line to the code

  System.out.println (replace all (msg, "", ""));   

Also add as a pattern

  All the public string strings replaced (string source, string pattern, string replacement) {if (source == empty ) Return ""; Stringbuffer sb = new stringbuffer (); Int idx = -1; Int patIdx = 0; While ((idx = source.indexOf (pattern, patIdx)) -1 - {sb.append (source.substring (patIdx, idx)); Sb.append (replacement); PatIdx = idx + pattern.length (); } Sb.append (source.substring (patIdx)); Return sb.toString (); }   

It replaces all the spaces with empty string, which you want.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -