Split string with dot as delimiter

split() accepts a regular expression, so you need to escape . to not consider it as a regex meta character. Here’s an example :

String[] fn = filename.split("\\."); 
return fn[0];

Leave a Comment