Skip to content

Instantly share code, notes, and snippets.

@mourawaldson
Created April 28, 2012 21:35
Show Gist options
  • Save mourawaldson/2522202 to your computer and use it in GitHub Desktop.
Save mourawaldson/2522202 to your computer and use it in GitHub Desktop.
Get file extension
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());
}
@ABaker86
Copy link

ABaker86 commented Nov 6, 2013

Shouldn't file be path as you are not actually passing a file object but a String path? Regardless I was able to get this to work just fine.

@mourawaldson
Copy link
Author

Yes, can be!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment