List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getMimeType(String url) { String mime = null;/*from w w w. j av a 2 s . c o m*/ int dot = url.lastIndexOf('.'); if (dot >= 0) mime = (String) theMimeTypes.get(url.substring(dot + 1).toLowerCase()); if (mime == null) mime = "application/octet-stream"; return mime; }
From source file:Main.java
private static String removeTag(String xml) { int start = xml.indexOf('>') + 1; int end = xml.lastIndexOf('<'); return xml.substring(start, end); }
From source file:Main.java
public static String getResourceId(String resourcePath) { return resourcePath.substring(resourcePath.lastIndexOf('/') + 1); }
From source file:Main.java
private static char getType(Object object) { if (isArray(object)) { String str = object.toString(); return str.substring(str.lastIndexOf("[") + 1, str.lastIndexOf("[") + 2).charAt(0); }/*w w w .j a v a2 s . c o m*/ return 0; }
From source file:Main.java
private static String getPackage(String classRef) { int lastSlash = classRef.lastIndexOf('/'); if (lastSlash < 0) { return ""; }//from w w w.j av a2 s. c om return classRef.substring(1, lastSlash); }
From source file:Main.java
/** * Get the extension of a file.// ww w. j ava 2 s. c o m */ public static String getExtension(File f) { String ext = null; String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) { ext = s.substring(i + 1).toLowerCase(); } return ext; }
From source file:Main.java
private static String getMimeType(File file) { String name = file.getName(); int index = name.lastIndexOf("."); if (index == -1) return "*/*"; return "application/" + name.substring(index + 1); }
From source file:Main.java
private static String getFileNameFromPath(String path) { String name = null;/*from w w w . j a v a 2 s . c o m*/ if (path != null && path.lastIndexOf("/") + 1 < path.length()) { name = path.substring(path.lastIndexOf("/") + 1); } return name; }
From source file:Main.java
static String getExtention(String fileName) { String extension = ""; int i = fileName.lastIndexOf('.'); if (i > 0) { extension = fileName.substring(i + 1); }/*from ww w .j ava 2 s . c o m*/ return extension; }
From source file:Main.java
private static File createTempFile(String filename) { try {/*from w w w . j a v a 2 s . c o m*/ int dotIndex = filename.lastIndexOf("."); String prefix = filename.substring(0, dotIndex); String suffix = filename.substring(dotIndex + 1); File temp = File.createTempFile(prefix, suffix); temp.deleteOnExit(); return temp; } catch (Exception e) { throw new RuntimeException("Could not create temp file: " + filename, e); } }