java - Someone Please Explain to me this part of Code -



java - Someone Please Explain to me this part of Code -

public string extension(file f) { string filename = f.getname(); int lastindex = filename.lastindexof(dotsymbol); if(lastindex > 0 && lastindex <filename.length() -1) { homecoming filename.substring(lastindex+1); }else { homecoming "";

i don't understand why need decrement 1 if statement , add together 1 substring.

you finding lastly position of string has dot. if find dot homecoming substring after dot (this gets file extension). subtract one, because if dot lastly character of string have no file extension. add together one, because don't want homecoming dot, want homecoming what's after dot (the file extension).

java filefilter

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -