Removing all empty elements from an character array

后端 未结 5 2056
面向向阳花
面向向阳花 2021-01-15 11:07

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

5条回答
  •  我在风中等你
    2021-01-15 11:54

    StringWriter writer = new StringWriter();
    IOUtils.copy(inputStream, writer, encoding);
    String theString = writer.toString();
    

    OR

    String theString = IOUtils.toString(inputStream, "UTF-8");
    

提交回复
热议问题