Back to project page android-common-utility.
The source code is released under:
Apache License
If you think the Android project android-common-utility listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.xckevin.android.util; /*from ww w . j av a 2 s. co m*/ import java.io.File; import java.util.UUID; /** * file utilities * * @author Kevin */ public class FileUtils { /** * get file name from url * * @param url * @return */ public static String getFileNameByUrl(String url) { if (StringUtil.isEmpty(url)) { return null; } int index = url.lastIndexOf('?'); int index2 = url.lastIndexOf("/"); if (index > 0 && index2 >= index) { return UUID.randomUUID().toString(); } return url.substring(index2 + 1, index < 0 ? url.length() : index); } /** * get file extend name * * @param fileName * @return */ public static String getFileExtendName(String fileName) { if (StringUtil.isEmpty(fileName)) { return null; } int index = fileName.lastIndexOf('.'); if (index < 0) { return "unknown"; } else { return fileName.substring(index + 1); } } public static boolean isFileExists(String filePath) { if (StringUtil.isEmpty(filePath)) { return false; } return new File(filePath).exists(); } }