lastIndexOf() private méthode

private lastIndexOf ( global par0 ) : int
par0 global
Résultat int
		public static String getDirectoryName(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				int index2 = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				if (index2 > index) {
					index = index2;
				}
				if (index != -1) {
					if (index == path.length() - 1) {
						if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
							return null;
						} else {
							path = path.substring(0, index);
						}
					} else {
						if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
							path = path.substring(0, index + 1);
						} else {
							path = path.substring(0, index);
						}
					}
					if (path.length() == 2 && path[1] == VOLUME_SEPARATOR_CHAR) {
						return "";
					}
				}
				return path;
			}
			return null;
		}
		public static String getFileName(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				if (index == -1) {
					index = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				}
				if (index == -1) {
					return path;
				}
				return path.substring(index + 1);
			}
			return null;
		}
		public static String getFileNameWithoutExtension(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				if (index == -1) {
					index = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				}
				if (index != -1) {
					path = path.substring(index + 1);
				}
				index = path.lastIndexOf('.');
				if (index == -1) {
					return path;
				}
				return path.substring(0, index);
			}
			return null;
		}
		public static String getExtension(String path) {
			if (path != null) {
				int index = path.lastIndexOf('.');
				if (index == -1) {
					return "";
				}
				return path.substring(index);
			}
			return null;
		}
		public static bool hasExtension(String path) {
			int index = path.lastIndexOf('.');
			if (index == -1) {
				return false;
			}
			return (index + 1) != path.length();
		}
 public new /*synchronized*/ int lastIndexOf(String str, int fromIndex)
 {
     return(String.lastIndexOf(value, 0, count,
                               str.toCharArray(), 0, str.length(), fromIndex));
 }
Exemple #7
0
 public virtual int lastIndexOf(String str, int fromIndex)
 {
     return(String.lastIndexOf(value, 0, count,
                               str.toCharArray(), 0, str.length(), fromIndex));
 }