Java 截取字符串中指定的分隔符放入list中
public static void main(String[] args) { String x1="\"073126\"\t\"19994772005\"\t\"2020-10-28 00:07:20\"\t\"2020-10-28 00:08:27\"\t\"DELIVRD\"\t\"DELIVRD\"\t\"ninde\""; StringTokenizer x2=new StringTokenizer(x1,"\""); List<String> list=new ArrayList<String>(); while(x2.hasMoreTokens()){ list.add(x2.nextToken()); } for (String s : list) { System.out.println(s); }
输出显示