I have a character array that can hold maximum 50000 characters at a time. Contents of this array are coming through socket connections. However it is not guaranteed that th
I would suggest converting the array to a string and using the replaceAll and trim functions to remove the empty elements.
String bufferString = new String(buffer).trim().replaceAll(" ", "");
This does not require any additional libraries.