I want to call a PHP webservice from my J2ME program. Here is the PHP function called :
...
$req="SELECT DISTINCT a.adc_id FROM adc a INNER JOIN utilisateur u ON a.adc_id=u.adc_id INNER JOIN transfert t ON u.user_code = t.user_code
WHERE t.user_code ='". $user_code ."' AND t.date_transfert='".$datejour."'";
$query=mysql_query($req) ;
while($ligne = mysql_fetch_array($query))
{
$chaine .=$ligne['adc_id'].';';
$chaine .= "\r\n" ;
}
return $chaine;
As you see there is the “\r\n” new-line character returned by the webservice among the column data. For example the returned String is :
12011;Michael;12/12/2012;
13455;Sue;14/05/2011;
So how to “split” this String data in J2ME so that I will get an array String[] containing the values :
12011;Michael;12/12/2012; and 13455;Sue;14/05/2011; ?
You will either have to write your own tokenizer or use one of the many available on the net.
One example could be this one from nokia’s page
Usage example: