Truncating Strings by Bytes

后端 未结 13 1733
醉酒成梦
醉酒成梦 2021-02-06 04:21

I create the following for truncating a string in java to a new string with a given number of bytes.

        String truncatedValue = \"\";
        String curren         


        
13条回答
  •  灰色年华
    2021-02-06 04:50

    By using below Regular Expression also you can remove leading and trailing white space of double byte character.

    stringtoConvert = stringtoConvert.replaceAll("^[\\s ]*", "").replaceAll("[\\s ]*$", "");
    

提交回复
热议问题