Android examples for java.lang:String Parse
get Numbers From String
//package com.java2s; import java.util.Set; import java.util.TreeSet; public class Main { public static Set<Integer> getNumsFromStr(String text) { text = null == text ? "" : text; String[] ary = text.replaceAll("[^\\d]", " ").split("\\s+"); Set<Integer> set = new TreeSet<Integer>(); for (String num : ary) { if (!num.trim().equals("")) { set.add(Integer.valueOf(num.trim())); }/*from w w w . java 2 s . c om*/ } return set; } }