Utils { public static String getFileNameWithoutExtension(String path) { int lastSlash = path.lastIndexOf("/"); if (lastSlash <= 0) { return ""; } int lastDot = path.lastIndexOf("."); lastDot = lastDot > lastSlash ? lastDot : path.length(); return path.substring(lastSlash + 1, lastDot); }  static boolean isNetworkAvailable(Context context); boolean isExternalStorageWritable(); boolean isExternalStorageReadable(); static String readFile(String pathname); static String getFolder(String path); static String getFileNameWithoutExtension(String path); static Set<Integer> loadHiddenFoldersFromDisk(Context context); static void writeHiddenFolders(Context context); static void addHiddenFolder(Context context, int folderHash); static void removeHiddenFolder(Context context, int folderHash); static final String PREFERENCE_NAME; static final String HIDE_FOLDER_PREF_KEY; }
@Test public void getFileName() { String res = Utils.getFileNameWithoutExtension("/storage/sdcard0/images/abc.pic"); assertEquals("abc", res); res = Utils.getFileNameWithoutExtension("/storage/sdcard0/images/abc"); assertEquals("abc", res); res = Utils.getFileNameWithoutExtension("/storage/sdcard0/im.ages/abc."); assertEquals("abc", res); }