split()accepts a regular expression (see split (java.lang.String) ), not a separator string to separate. A regular expression "."means "any single character" (see regex ), so it will be split into anything that will not remain on the list. To split into a literal dot, use:
file.getName().split("\\.")// \. escapes . in regex \\ escapes \ in Java.String
Pattern.quote(str) , str . ( ramon)
file.getName().split(Pattern.quote("."))