From 766064092ca4f85eacfa741e1ff772ea5b981d1a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Oct 2015 11:09:14 +1300 Subject: Handle empty capture groups --- src/org/traccar/helper/Parser.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java index 9b346d810..e89104094 100644 --- a/src/org/traccar/helper/Parser.java +++ b/src/org/traccar/helper/Parser.java @@ -45,15 +45,23 @@ public class Parser { } public int nextInt() { - return Integer.parseInt(next()); + return nextInt(10); } public int nextInt(int radix) { - return Integer.parseInt(next(), radix); + if (hasNext()) { + return Integer.parseInt(next(), radix); + } else { + return 0; + } } public double nextDouble() { - return Double.parseDouble(next()); + if (hasNext()) { + return Double.parseDouble(next()); + } else { + return 0.0; + } } // Format: (degrees)(minutes)(hemisphere) -- cgit v1.2.3