From c223d4e4ec4e908d12776f22f48b99ff4525aed1 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: 星期三, 27 一月 2021 15:31:31 +0800 Subject: [PATCH] 增加数据格式检验,避免设备返回错误格式造成抛错误 --- src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java new file mode 100644 index 0000000..4dc6307 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java @@ -0,0 +1,25 @@ +package com.genersoft.iot.vmp.gb28181.utils; + +/** + * 鏁板�兼牸寮忓垽鏂拰澶勭悊 + * @author lawrencehj + * @date 2021骞�1鏈�27鏃� + */ +public class NumericUtil { + + /** + * 鍒ゆ柇鏄惁Double鏍煎紡 + * @param str + * @return true/false + */ + public static boolean isDouble(String str) { + try { + Double num2 = Double.valueOf(str); + System.out.println("Is Number!" + num2); + return true; + } catch (Exception e) { + System.out.println("Is not Number!"); + return false; + } + } +} -- Gitblit v1.8.0