public static void main( String[] args ) throws IOException
    {
        String str = "a|b";
        String[] strs = str.split("[|]");
        System.out.println(strs.length);
        if(strs.length>0){
            for(String s : strs){
                System.out.println("===:"+s);
            }
        }
        System.out.println(Arrays.asList(str.split("[|]")));
         
    }

结果:

2
===:a
===:b
[a, b]

相关文章:

  • 2021-08-27
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-06-13
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2022-01-15
  • 2022-01-22
  • 2021-12-03
相关资源
相似解决方案