List of usage examples for java.lang StringBuffer lastIndexOf
@Override public synchronized int lastIndexOf(String str, int fromIndex)
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); int position = phrase.lastIndexOf("three", 6); System.out.println(position); }
From source file:Main.java
public static void main(String[] arg) { StringBuffer buffer = new StringBuffer("from java2s.com"); System.out.println(buffer.lastIndexOf("a", 10)); }
From source file:Main.java
private static String removeSingleQuotes(StringBuffer tempBuffer, int questionSignIndex) { int delRightIndex = tempBuffer.indexOf("'", questionSignIndex); int delLeftIndex = tempBuffer.lastIndexOf("'", questionSignIndex); if (isDelSingleQuotes(tempBuffer, delLeftIndex, delRightIndex)) { tempBuffer.deleteCharAt(delRightIndex); tempBuffer.deleteCharAt(delLeftIndex); }/* w w w. ja v a 2 s . c o m*/ return tempBuffer.toString(); }
From source file:org.talend.designer.runprocess.java.JavaProcessor.java
/** * DOC chuang Comment method "computeMethodSizeIfNeeded". * /*from w w w .j a va 2 s . c o m*/ * @param processCode * @return */ private String computeMethodSizeIfNeeded(String processCode) { // must match TalendDesignerPrefConstants.DISPLAY_METHOD_SIZE boolean displayMethodSize = Boolean.parseBoolean( CorePlugin.getDefault().getDesignerCoreService().getPreferenceStore("displayMethodSize")); //$NON-NLS-1$ if (displayMethodSize) { StringBuffer code = new StringBuffer(processCode); int fromIndex = 0; while (fromIndex != -1 && fromIndex < code.length()) { int methodStartPos = code.indexOf(METHOD_START_COMMENT, fromIndex); if (methodStartPos < 0) { break; } int sizeCommentPos = code.indexOf(SIZE_COMMENT, fromIndex); // move ahead to the start position of source code methodStartPos = code.indexOf("*/", sizeCommentPos) + 2; //$NON-NLS-1$ int methodEndPos = code.indexOf(METHOD_END_COMMENT, fromIndex); if (methodEndPos < 0) { break; } // start position for next search fromIndex = methodEndPos + METHOD_END_COMMENT.length(); // go back to the end position of source code methodEndPos = code.lastIndexOf("/*", methodEndPos); //$NON-NLS-1$ int size = methodEndPos - methodStartPos; code.replace(sizeCommentPos, sizeCommentPos + SIZE_COMMENT.length(), String.valueOf(size)); } return code.toString(); } else { return processCode; } }