Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get a file extension

807588Jul 5 2009 — edited Jul 5 2009
I wonder how to get the portion of text after the last dot in a string.

For example to get .java from my.project.java or .jpg from my-photo.jpg
String[] parts = "test.test.test".split(".");
if(parts.length == 0) return false;
return true;
For some reason it returns false!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 2 2009
Added on Jul 5 2009
4 comments
155 views