Last active
February 5, 2018 16:46
-
-
Save geolimber/a167c936035e09a6041a8c2a5ebac9b7 to your computer and use it in GitHub Desktop.
Simple java class to get file extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple java class to get file extension. | |
* Returns null if file starts with point, like .htaccess, and if the file don't have any extension. | |
* Created by Sergio Marchenko on 05-05-2017. | |
*/ | |
public class ExtensionChecker { | |
public static String getFileExtension(String fileName) { | |
if (!fileName.startsWith(".") && fileName.contains(".")) { | |
return fileName.substring(fileName.lastIndexOf(".") + 1); | |
} | |
else return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment