Java tutorial
//package com.java2s; public class Main { public static boolean checkGpgga(String checkString) { if (!checkString.contains("*")) return false; if (checkString.indexOf("*") + 4 > checkString.length()) return false; String checkMain = checkString.substring(checkString.indexOf("*") + 1, checkString.indexOf("*") + 3); String bufferString = getCheckNum(checkString); if (checkMain == null || bufferString == null) return false; return checkMain.toUpperCase().equals(bufferString.toUpperCase()); } public static String getCheckNum(String ggaString) { if (!ggaString.contains("$") || !ggaString.contains("*")) return null; String test = ggaString.substring(ggaString.indexOf("$") + 1, ggaString.indexOf("*")); char result = test.charAt(0); for (int i = 1; i < test.length(); i++) result ^= test.charAt(i); String bufferString = Integer.toHexString(result); if (bufferString.length() == 1) bufferString = "0".concat(bufferString); return bufferString; } }