From a183f2292f050a535fa98d87535d22ec4e81d647 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 31 Jan 2023 15:13:53 +0100 Subject: [PATCH] Continued: - added more checks on parameter --- .../mxchange/jcore/utils/FrameworkUtils.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/org/mxchange/jcore/utils/FrameworkUtils.java b/src/org/mxchange/jcore/utils/FrameworkUtils.java index aef9ac0..dd6ab58 100644 --- a/src/org/mxchange/jcore/utils/FrameworkUtils.java +++ b/src/org/mxchange/jcore/utils/FrameworkUtils.java @@ -52,8 +52,23 @@ public class FrameworkUtils { * @return Array from tokenized string */ public static String[] getArrayFromString (final String str, final String delimiter) { + // Check all parameter + if (null == str) { + // Throw NPE + throw new NullPointerException("Parameter 'str' is null"); //NOI18N + } else if (str.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("Parameter 'str' is empty"); //NOI18N + } else if (null == delimiter) { + // Throw NPE + throw new NullPointerException("Parameter 'delimiter' is null"); //NOI18N + } else if (delimiter.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("Parameter 'delimiter' is empty"); //NOI18N + } + // Get tokenizer - StringTokenizer tokenizer = new StringTokenizer(str, delimiter); + final StringTokenizer tokenizer = new StringTokenizer(str, delimiter); // Init array and index String[] tokens = new String[tokenizer.countTokens()]; -- 2.39.5