Here you can find the source of lastIndexOf(final String input, final char delim)
Parameter | Description |
---|---|
input | The string to be searched |
delim | The character to be found |
public static int lastIndexOf(final String input, final char delim)
//package com.java2s; public class Main { /**/*from w w w . j a v a 2s . co m*/ * Gets the last index of a character ignoring characters that have been escaped * * @param input The string to be searched * @param delim The character to be found * @return The index of the found character or -1 if the character wasn't found */ public static int lastIndexOf(final String input, final char delim) { return input == null ? -1 : lastIndexOf(input, delim, input.length()); } /** * Gets the last index of a character starting at fromIndex. Ignoring characters that have been escaped * * @param input The string to be searched * @param delim The character to be found * @param fromIndex Start searching from this index * @return The index of the found character or -1 if the character wasn't found */ public static int lastIndexOf(final String input, final char delim, final int fromIndex) { if (input == null) return -1; int index = input.lastIndexOf(delim, fromIndex); while (index != -1 && index != 0) { if (input.charAt(index - 1) != '\\') break; index = input.lastIndexOf(delim, index - 1); } return index; } }