List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:Main.java
public static void main(String[] arg) { String string1 = "abcde"; if (string1.startsWith("ab")) { System.out.println("starts with ab"); }// ww w . j a v a 2s .c o m }
From source file:Main.java
public static void main(String[] args) { String strOrig = "Hello World"; if (strOrig.startsWith("Hello")) { System.out.println("String starts with Hello"); } else {/*www. ja v a 2 s . c om*/ System.out.println("String does not start with Hello"); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { File dir = new File("c:\\temp"); FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return !name.startsWith("."); }//from w w w . j a v a 2 s . c o m }; String[] children = dir.list(filter); }
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 www . ja va 2 s. co m System.out.println(entry); } }
From source file:Main.java
public static void main(String[] args) { ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US); Enumeration<String> keys = bundle.getKeys(); ArrayList<String> temp = new ArrayList<String>(); for (Enumeration<String> e = keys; keys.hasMoreElements();) { String key = e.nextElement(); if (key.startsWith("java2s")) { temp.add(key);//from w ww.j a va2s . co m } } String[] result = new String[temp.size()]; for (int i = 0; i < temp.size(); i++) { result[i] = bundle.getString(temp.get(i)); } System.out.println(Arrays.toString(result)); }
From source file:eu.europeana.datamigration.ese2edm.LogCleaner.java
public static void main(String[] args) { try {//from ww w . j a v a 2 s .com List<String> lines = FileUtils.readLines(new File("/home/gmamakis/test.log")); List<String> newLines = new ArrayList<String>(); for (String line : lines) { if (!line.startsWith("Apr")) { newLines.add(line); } } FileUtils.writeLines(new File("/home/gmamakis/rdfslabel.log"), newLines); } catch (IOException ex) { Logger.getLogger(LogCleaner.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.swarmcom.jsynapse.JSynapseServer.java
public static void main(String[] args) { if (args.length > 0) { for (String arg : args) { if (arg.startsWith("--domain")) { DOMAIN = substringAfter(arg, "="); }/* ww w. j a v a 2s.c o m*/ } } run(JSynapseServer.class, args); }
From source file:Main.java
public static void main(String[] args) { String str = "This is a test"; // Test str, if it starts with "This" if (str.startsWith("This")) { System.out.println("String starts with This"); } else {/*from w w w . j a v a2 s . c om*/ System.out.println("String does not start with This"); } // Test str, if it ends with "program" if (str.endsWith("program")) { System.out.println("String ends with program"); } else { System.out.println("String does not end with program"); } }
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)); }//w w w. j a va 2s. c o m } } System.out.println(result); }
From source file:com.mtag.trafficservice.TrafficApplication.java
public static void main(String[] args) { for (String arg : args) { String a = arg.toLowerCase(); if (a.startsWith("--port=")) { Integer port = new Integer(a.substring(7)); if (port != null) { ServerCustomizationBean.port = port; }// w ww .j av a2s. c om } else { System.out.println("--- unknown argument '" + arg + "' ---"); System.out.println(); System.out.println("options are:"); System.out.println("--port=n change http-port to n (default is 8080)"); System.out.println(); } } // new AnnotationConfigApplicationContext(Tra) SpringApplication.run(TrafficApplication.class, args); }