Java String Last Index Of lastIndexOf(StringBuffer buf, String str)

Here you can find the source of lastIndexOf(StringBuffer buf, String str)

Description

Performs the equivalent of buf.toString().lastIndexOf(str), but is much more memory efficient.

License

Open Source License

Declaration

public static int lastIndexOf(StringBuffer buf, String str) 

Method Source Code

//package com.java2s;
/*//from w w  w .j  a  v a  2  s  .c o  m
StringUtils.java : A stand alone utility class.
Copyright (C) 2000 Justin P. McCarthy
    
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
    
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.
    
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
    
To further contact the author please email jpmccar@gjt.org
    
    
Modifications, copyright 2001-2014 Tuma Solutions, LLC; distributed under the
LGPL, as described above.
    
*/

public class Main {
    /** Performs the equivalent of buf.toString().lastIndexOf(str), but is
     *  much more memory efficient. */
    public static int lastIndexOf(StringBuffer buf, String str) {
        return lastIndexOf(buf, str, buf.length());
    }

    /** Performs the equivalent of buf.toString().lastIndexOf(str, fromIndex),
     *  but is much more memory efficient. */
    public static int lastIndexOf(StringBuffer buf, String str, int fromIndex) {
        // This method didn't exist in Java 1.3, but does now.
        return buf.lastIndexOf(str, fromIndex);
    }
}

Related

  1. lastIndexOf(String string, char... chars)
  2. lastIndexOf(String string, String substring)
  3. lastIndexOf(String text, int startPos, String... searchStrings)
  4. lastIndexOf(String text, String key, int num)
  5. lastIndexOf(String what, String within)
  6. lastIndexOfAny(final String delimiters, final String str)
  7. lastIndexOfAny(String str, String search, int offset)
  8. lastIndexOfAnyBut(String srcString, String validString)
  9. lastIndexOfAnyDelimiter(String str, int fromIndex, String delimiters)