Split string with dot as delimiter

后端 未结 13 2463
死守一世寂寞
死守一世寂寞 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:13

    Usually its NOT a good idea to unmask it by hand. There is a method in the Pattern class for this task:

    java.util.regex
    static String quote(String s) 
    

提交回复
热议问题