List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:MainClass.java
public static void main(String[] args) { try {/*from w w w . j a v a 2 s .com*/ Class c = Class.forName("java.util.ArrayList"); Constructor constructors[] = c.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { System.out.print(constructors[i].getName() + ": "); Class parameters[]; parameters = constructors[i].getParameterTypes(); for (int j = 0; j < parameters.length; j++) { String s = parameters[j].getName(); s = s.substring(s.lastIndexOf(".") + 1, s.length()); System.out.print(s + " "); } System.out.println(""); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { try {/*from w w w .j av a2s. c o m*/ Class c = Class.forName("java.util.ArrayList"); Constructor constructors[] = c.getConstructors(); for (int i = 0; i < constructors.length; i++) { System.out.print(constructors[i].getName() + ": "); Class parameters[]; parameters = constructors[i].getParameterTypes(); for (int j = 0; j < parameters.length; j++) { String s = parameters[j].getName(); s = s.substring(s.lastIndexOf(".") + 1, s.length()); System.out.print(s + " "); } System.out.println(""); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) { String letters = "abcdefghijklmabcdefghijklm"; System.out.printf("Last 'c' is located at index %d\n", letters.lastIndexOf('c')); System.out.printf("Last 'a' is located at index %d\n", letters.lastIndexOf('a', 25)); System.out.printf("Last '$' is located at index %d\n\n", letters.lastIndexOf('$')); }
From source file:MainClass.java
public static void main(String args[]) { String letters = "abcdefghijklmabcdefghijklm"; System.out.printf("Last \"def\" is located at index %d\n", letters.lastIndexOf("def")); System.out.printf("Last \"def\" is located at index %d\n", letters.lastIndexOf("def", 25)); System.out.printf("Last \"hello\" is located at index %d\n", letters.lastIndexOf("hello")); }
From source file:Main.java
public static void main(String args[]) { String s = "this is a test from java2s.com."; System.out.println(s);/*from ww w . j a va2s .com*/ System.out.println("lastIndexOf(t) = " + s.lastIndexOf('t')); }
From source file:Main.java
public static void main(String args[]) { String s = "this is a test from java2s.com."; System.out.println(s);/*ww w.j ava 2 s . c o m*/ System.out.println("lastIndexOf(the) = " + s.lastIndexOf("the")); }
From source file:MainClass.java
public static void main(String args[]) { String s = "public static void main(String args[]) {"; System.out.println(s);/* ww w .j a va 2 s. c om*/ System.out.println("lastIndexOf(the) = " + s.lastIndexOf("pub")); }
From source file:com.github.zerkseez.codegen.wrappergenerator.Main.java
public static void main(final String[] args) throws Exception { final Options options = new Options(); options.addOption(Option.builder().longOpt("outputDirectory").hasArg().required().build()); options.addOption(Option.builder().longOpt("classMappings").hasArgs().required().build()); final CommandLineParser parser = new DefaultParser(); try {/* w w w. ja v a2s . c o m*/ final CommandLine line = parser.parse(options, args); final String outputDirectory = line.getOptionValue("outputDirectory"); final String[] classMappings = line.getOptionValues("classMappings"); for (String classMapping : classMappings) { final String[] tokens = classMapping.split(":"); if (tokens.length != 2) { throw new IllegalArgumentException( String.format("Invalid class mapping format \"%s\"", classMapping)); } final Class<?> wrappeeClass = Class.forName(tokens[0]); final String fullWrapperClassName = tokens[1]; final int indexOfLastDot = fullWrapperClassName.lastIndexOf('.'); final String wrapperPackageName = (indexOfLastDot == -1) ? "" : fullWrapperClassName.substring(0, indexOfLastDot); final String simpleWrapperClassName = (indexOfLastDot == -1) ? fullWrapperClassName : fullWrapperClassName.substring(indexOfLastDot + 1); System.out.println(String.format("Generating wrapper class for %s...", wrappeeClass)); final WrapperGenerator generator = new WrapperGenerator(wrappeeClass, wrapperPackageName, simpleWrapperClassName); generator.writeTo(outputDirectory, true); } System.out.println("Done"); } catch (MissingOptionException e) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(String.format("java -cp CLASSPATH %s", Main.class.getName()), options); } }
From source file:com.aws.sampleImage.url.TestHttpGetFlickrAPI.java
public static void main(String[] args) throws IOException, JSONException { //String query = "church"; //String query = "sukriti"; String query = "people"; System.out.println(callFlickrAPIForEachKeyword(query)); String abc = "abcdef)"; System.out.println(abc.substring(0, abc.lastIndexOf(")"))); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Click me"); button.addActionListener(e -> {//w w w . j a va2 s .co m JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(new File(chooser.getCurrentDirectory(), "save.dat")); final JTextField textField = getTexField(chooser); if (textField == null) { return; } String text = textField.getText(); if (text == null) { return; } int index = text.lastIndexOf('.'); if (index == -1) { return; } textField.setSelectionStart(0); textField.setSelectionEnd(index); chooser.showSaveDialog(button); }); frame.add(button); frame.pack(); frame.setVisible(true); }