String split '.'

public static void splitByDot()
    {
        String s = "abc.def.lkj";
        String[] strs = s.split(".");
        
        System.out.println("strs Length: "+strs.length);
        
        // 运行输出: strs Length: 0
    }
    // '.' 好像为转义字符。 使用 '\\.' 即可
    public static void splitByDot_()
    {
        String s = "abc.def.lkj";
        String[] strs = s.split("\\.");
        
        for(String str:strs)
        System.out.println(str);
        //这样就行了,运行输出
        /*
         abc
         def
         lkj
        */
    }
原文地址:https://www.cnblogs.com/laoquans/p/3090097.html