List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getFileNameWithExtention(String url) { String fileName;/*from www.j a va 2 s. c o m*/ int slashIndex = url.lastIndexOf("/"); int qIndex = url.lastIndexOf("?"); if (qIndex > slashIndex) {//if has parameters fileName = url.substring(slashIndex + 1, qIndex); } else { fileName = url.substring(slashIndex + 1); } return fileName; }
From source file:Main.java
public static String getMIMEType(File var0) { String var1 = ""; String var2 = var0.getName(); String var3 = var2.substring(var2.lastIndexOf(".") + 1, var2.length()).toLowerCase(); var1 = MimeTypeMap.getSingleton().getMimeTypeFromExtension(var3); return var1; }
From source file:Main.java
public static Double getTotalWeightFromNBestLine(String nBestLine) { int firstIndexWeightSubstring = nBestLine.lastIndexOf(JOSHUA_SEPARATOR) + JOSHUA_SEPARATOR.length(); String weightSubstring = nBestLine.substring(firstIndexWeightSubstring); return Double.parseDouble(weightSubstring); }
From source file:Main.java
public static String getFileExtension(String url) { String extenstion;// w ww. j a v a 2 s. co m int pointIndex = url.lastIndexOf("."); int qIndex = url.lastIndexOf("?"); if (qIndex > pointIndex) { extenstion = url.substring(pointIndex + 1, qIndex); } else { extenstion = url.substring(pointIndex + 1); } return extenstion; }
From source file:Main.java
public static final String getExtensionWithDot(final File file) { if (file == null) { return ""; }/*from ww w.ja v a 2 s .c om*/ final String name = file.getName(); final int index = name.lastIndexOf("."); if (index == -1) { return ""; } return name.substring(index); }
From source file:Main.java
/** * Please do not use - internal/*from w ww . j ava 2 s . c o m*/ * org/my/Class.xxx -> org/my/Class */ public static String stripExtension(final String pResourceName) { final int i = pResourceName.lastIndexOf('.'); return pResourceName.substring(0, i); }
From source file:Main.java
/** * Compute the name of the last part of the path. * // w w w. ja v a 2 s . c o m * @param path the path, eg "./elem" or "elem". * @return the name, eg "elem". */ public final static String basename(String path) { return path.substring(path.lastIndexOf('/') + 1); }
From source file:Main.java
public static String getDirectory(String iPath) { iPath = getPath(iPath);/* w w w. j av a 2 s .co m*/ int pos = iPath.lastIndexOf("/"); if (pos == -1) return ""; return iPath.substring(0, pos); }
From source file:Main.java
public static String getDirectoryForFile(String filepath) { int i = filepath.lastIndexOf(File.separator); if (i == -1)//from w ww . j ava 2s .co m return filepath; else return filepath.substring(0, i); }
From source file:Main.java
public static String getMimeType(String url) { String mime = null;//from w w w . j a v a 2 s. co m int dot = url.lastIndexOf('.'); if (url.contains(".m3u8")) { mime = "video/mp4"; return mime; } if (dot >= 0) mime = (String) theMimeTypes.get(url.substring(dot + 1).toLowerCase()); if (mime == null) mime = "application/octet-stream"; return mime; }