List of usage examples for java.lang String substring
public String substring(int beginIndex)
From source file:Main.java
public static void main(String[] argv) { String str = "java2s.com"; System.out.println(str.substring(2)); }
From source file:MainClass.java
public static void main(String[] arg) { String place = "abcedfghijk"; String lastWord = place.substring(5); System.out.println(lastWord); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Class cls = java.util.Map.Entry.class; String name = cls.getName(); if (name.lastIndexOf('.') > 0) { name = name.substring(name.lastIndexOf('.') + 1); // Map$Entry name = name.replace('$', '.'); // Map.Entry }/*from w ww . ja v a 2s. com*/ }
From source file:Main.java
public static void main(String[] args) { String[] ids = TimeZone.getAvailableIDs(); for (String id : ids) { int slash = id.indexOf('/'); String stripped = id.substring(slash + 1).replace("_", " "); System.out.println(stripped); }/* www . j a v a2s.c o m*/ }
From source file:MainClass.java
public static void main(String args[]) { String s1 = "The total cost is $45.67"; int i1 = s1.indexOf('$'); String s2 = s1.substring(i1); System.out.println(s2);//from w w w. ja v a 2 s. c o m }
From source file:SubStringDemo.java
public static void main(String[] av) { String a = "Java is great."; System.out.println(a);//ww w.j a va 2 s . c o m String b = a.substring(5); // b is the String "is great." System.out.println(b); String c = a.substring(5, 7);// c is the String "is" System.out.println(c); String d = a.substring(5, a.length());// d is "is great." System.out.println(d); }
From source file:MainClass.java
public static void main(String[] args) { Provider provider = Security.getProvider("BC"); Iterator it = provider.keySet().iterator(); while (it.hasNext()) { String entry = (String) it.next(); if (entry.startsWith("Alg.Alias.")) { entry = entry.substring("Alg.Alias.".length()); }/*from w ww . j a v a 2 s .c o m*/ System.out.println(entry); } }
From source file:MainClass.java
public static void main(String args[]) { String letters = "abcdefghijklmabcdefghijklm"; // test substring methods System.out.printf("Substring from index 20 to end is \"%s\"\n", letters.substring(20)); System.out.printf("%s \"%s\"\n", "Substring from index 3 up to, but not including 6 is", letters.substring(3, 6));//from w ww . j a v a2 s . co m }
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 www . j a v a2 s . c om } } System.out.println(result); }
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 w w w . j a v a2 s. c o m*/ data = data.substring(0, data.indexOf('.')); result.add(data); } } for (Object o : result) { System.out.println("Service Type = " + o); } }