Created
April 28, 2012 21:35
-
-
Save mourawaldson/2522202 to your computer and use it in GitHub Desktop.
Get file extension
This file contains 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
import java.io.File; | |
/** | |
* Retorna a extensão do arquivo. | |
* | |
* @param file | |
* @return string Extensão | |
*/ | |
public static String getExtension(String file) { | |
return file.substring(file.lastIndexOf(".") + 1, file.length()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't
file
bepath
as you are not actually passing a file object but a String path? Regardless I was able to get this to work just fine.