List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:ClassUtil.java
public static String toPackagePath(Class<?> clazz) { String result = clazz.getName(); int index = result.lastIndexOf('.'); if (index < 1) { return ""; }/*from w w w . j a va 2 s. co m*/ result = result.substring(0, index); result = result.replace('.', '/'); return result; }
From source file:Main.java
public static CompressFormat GetCompressFormat(String name) { String extend = name.substring(name.lastIndexOf(".") + 1).toLowerCase(); if (extend.equals("png")) { return CompressFormat.PNG; }/* www. j a v a 2s .co m*/ return CompressFormat.JPEG; }
From source file:android.databinding.tool.util.ParserHelper.java
public static String stripExtension(String name) { final int dot = name.lastIndexOf('.'); return dot < 0 ? name : name.substring(0, dot); }
From source file:Main.java
public static String getFileExtension(File f) { if (f != null) { String filename = f.getName(); int i = filename.lastIndexOf('.'); if (i > 0 && i < filename.length() - 1) { return filename.substring(i + 1).toLowerCase(); }// ww w .java 2s .c o m } return null; }
From source file:Main.java
/** Returns the filename from an absolute filepath * @param filepath the filepath which contains a filename * @return the file name from the specified file. Attention, this method assumes that everything behind the * last slash "/" from the filepath corresponds to the filename! */ public static String getFilenameFromFilepath(String filepath) { int index = filepath.lastIndexOf("/"); return filepath.substring(index + 1, filepath.length()); }
From source file:Main.java
/** * Returns the class name portion of a fully-qualified binary class name. *///from ww w . j a v a 2s . c o m static String classNameOnly(String typeName) { int start = typeName.lastIndexOf("."); if (start < 0) { return typeName; } else { return typeName.substring(start + 1); } }
From source file:Main.java
/** * org/my/Class.xxx -> org/my/Class/* ww w. ja v a2 s . c o m*/ */ public static String stripExtension(final String pResourceName) { final int i = pResourceName.lastIndexOf('.'); if (i < 0) { return pResourceName; } final String withoutExtension = pResourceName.substring(0, i); return withoutExtension; }
From source file:Main.java
public static final String getPrefix(@NonNull String fileName) { return fileName.substring(0, fileName.lastIndexOf(".")); }
From source file:Util.java
public static String getUnqualifiedName(Class<?> clazz) { if (clazz == null) return ""; String name = clazz.getName(); return (name.substring(name.lastIndexOf('.') + 1)); }
From source file:Main.java
/** * Returns the package portion of a fully-qualified binary class name. *//* w w w . j av a 2 s . c o m*/ static String packageNameOnly(String typeName) { int end = typeName.lastIndexOf("."); if (end < 0) { /* lives in default package */ return ""; } else { return typeName.substring(0, end); } }