Intention is to take a current line (String that contains commas), replace white space with “” (Trim space) and finally store split String elements into the array.
Why does not this work?
String[] textLine = currentInputLine.replace("\\s", "").split(",");
I think you want replaceAll rather than replace.
And
replaceAll("\\s","")will remove all spaces, not just the redundant ones. If that’s not what you want, you should tryreplaceAll("\\s+","\\s")or something like that.