The problem is that instead of initializing your array, you set it to null. Try changing:
char[] strippedInput = null;
to
char[] strippedInput = new char[inputString.length()];
I understand that the strippedInput
will likely contain fewer characters than are in the inputString
. However, as far as I know, it is possible that you will need the same amount of characters in the stripped array. If you do not need all of them, just write a null character at the end the data and it will work/print correctly. Regardless, this will solve your NullPointerException
.