Sunday, 29 September 2013

How to get file extension in Java?

How to get file extension in Java?

I want to get all files with a specific extension. The following code is
working fine.
String extension = "";
int i = fileName.lastIndexOf('.');
if (i > 0) {
extension = fileName.substring(i+1);
}
But, could there be any better way to do?

No comments:

Post a Comment