Java String Last Index Of lastIndexOfPathSeparator(String str)

Here you can find the source of lastIndexOfPathSeparator(String str)

Description

last Index Of Path Separator

License

Apache License

Declaration

public static int lastIndexOfPathSeparator(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static int lastIndexOfPathSeparator(String str) {
        if (str == null)
            return -1;

        int length = str.length();
        for (int i = length - 1; i >= 0; i--) {
            char c = str.charAt(i);
            if (c == '/' || c == '\\') {
                return i;
            }//from w ww .  j  a v  a2 s . co m
        }

        return -1;
    }
}

Related

  1. lastIndexOfImpl(final String str, final String search, final int fromIndex, final boolean ignoreCase)
  2. lastIndexOfLetter(String string)
  3. lastIndexOfNewline(CharSequence theChars, int aStart)
  4. lastIndexOfNonWhitespace(final String src)
  5. lastIndexOfOrdinal(String value, String part, int startIndex, int count, boolean caseSensitive)
  6. lastIndexOfSeparator(String path)
  7. lastIndexOfUCL(String value)
  8. lastIndexOfUnnested(String str, char chr, String openBalance, String closeBalance)
  9. lastIndexOfWhitespace(String s)