从字符串中读取GPS $GPGGA数据,gpsgpgga,public stati
分享于 点击 43233 次 点评:219
从字符串中读取GPS $GPGGA数据,gpsgpgga,public stati
public static void parserGPSList(String str) { if (null == str || str.equals("")) { System.out.println("GPS数据为空,请检查!"); return; } else { int beginPosition = str.indexOf('$');//第一个含有‘$’位置 if (-1 != beginPosition) { while(-1 != beginPosition && '$' == str.charAt(beginPosition)) { String temp = str.substring(beginPosition, beginPosition + 6); if ("$GPGGA".equals(temp)) { int endPosition = str.indexOf('*', beginPosition); String gpsStr = str.substring(beginPosition, endPosition + 1); System.out.println(gpsStr); parserGPSItem(gpsStr);//具体解析gps item业务(代码未给出) beginPosition =str.indexOf('$', endPosition); }else{ beginPosition =str.indexOf('$', beginPosition+1); } } }else{ System.out.println("数据中不包含$GPGGA数据!"); } }}//该片段来自于http://byrx.net
用户点评