Split string with dot as delimiter

后端 未结 13 2233
死守一世寂寞
死守一世寂寞 2020-11-22 11:14

I am wondering if I am going about splitting a string on a . the right way? My code is:

String[] fn = filename.split(\".\");
return fn[0];
         


        
13条回答
  •  逝去的感伤
    2020-11-22 12:07

    split takes a regex as argument. So you should pass "\." instead of "." because "." is a metacharacter in regex.

提交回复
热议问题