List of usage examples for java.lang String split
public String[] split(String regex)
From source file:Main.java
public static void main(String[] args) { String FinalStringIs = ""; String testNames = "this is a test"; String[] name = testNames.split("\\s"); for (String nameIs : name) { FinalStringIs += getIntiCapString(nameIs) + ","; }/*from w w w.j a va 2s. c om*/ System.out.println("Final Result " + FinalStringIs); }
From source file:Main.java
public static void main(String[] args) { Set<Object> result = new HashSet<Object>(); Provider[] providers = Security.getProviders(); for (Provider provider : providers) { Set<Object> keys = provider.keySet(); for (Object key : keys) { String data = (String) key; data = data.split(" ")[0]; if (data.startsWith("Alg.Alias")) { data = data.substring(10); }//from www . jav a 2 s . com data = data.substring(0, data.indexOf('.')); result.add(data); } } for (Object o : result) { System.out.println("Service Type = " + o); } }
From source file:Main.java
public static void main(String[] args) { String str = "one,two,three,four,five"; String[] elements = str.split(","); for (int i = 0; i < elements.length; i++) System.out.println(elements[i]); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String inputStr = "a,,b"; String patternStr = ","; String[] fields = inputStr.split(patternStr); }
From source file:Main.java
public static void main(String[] args) { String text = "A,B,C,D"; String[] keyValue = text.split(","); Map<Integer, String> myMap = new HashMap<Integer, String>(); for (int i = 0; i < keyValue.length; i++) { myMap.put(i, keyValue[i]);/* ww w. j a v a 2s.c o m*/ } Set keys = myMap.keySet(); Iterator itr = keys.iterator(); while (itr.hasNext()) { Integer key = (Integer) itr.next(); String value = (String) myMap.get(key); System.out.println(key + " - " + value); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Set result = new HashSet(); String serviceType = "KeyFactory"; Provider[] providers = Security.getProviders(); for (int i = 0; i < providers.length; i++) { Set keys = providers[i].keySet(); for (Iterator it = keys.iterator(); it.hasNext();) { String key = (String) it.next(); key = key.split(" ")[0]; if (key.startsWith(serviceType + ".")) { result.add(key.substring(serviceType.length() + 1)); } else if (key.startsWith("Alg.Alias." + serviceType + ".")) { result.add(key.substring(serviceType.length() + 11)); }/*from w w w .ja v a 2 s.c om*/ } } System.out.println(result); }
From source file:MainClass.java
public static void main(String args[]) { String splitPattern = ","; String sentence = "This is a test, and that is another test."; String[] tokens = sentence.split(splitPattern); for (String s : tokens) { System.out.println(s);/* w ww.j a v a 2s. c o m*/ } }
From source file:Main.java
public static void main(String args[]) { String s = "this is a test this is a test"; String[] splitted = s.split(" "); Map<String, Integer> hm = new HashMap<String, Integer>(); for (int i = 0; i < splitted.length; i++) { if (hm.containsKey(splitted[i])) { int cont = hm.get(splitted[i]); hm.put(splitted[i], cont + 1); } else {/*from w w w . j av a 2 s .c om*/ hm.put(splitted[i], 1); } } System.out.println(hm); }
From source file:Main.java
public static void main(String[] args) { String str = "this is a test loooong test"; String stringArray[] = str.split("\\s"); String word = ""; for (int i = 0; i < stringArray.length; i++) { if (i == 0) { word = stringArray[0];/* w w w .j a v a2 s . co m*/ } word = compare(word, stringArray[i]); } System.out.println("Longest word = " + word); }
From source file:Main.java
public static void main(String[] args) { String input = "2x^4 - 45y^4"; input = input.replaceAll("\\D", " "); String[] parts = input.split("\\W+"); System.out.println(Arrays.toString(parts)); }