Might want to also check for last forward slash, in case the path portion of
the filename contains a dot.

E.g.:

/sdcard/.myapp/cachefile

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

05.09.2010 21:53 пользователь "Filip Havlicek" <[email protected]>
написал:

Well, you got it wrong i think :)

public static String fileExtension(File f) {
    String name = f.getName();
    int idx = name.lastI...
    if (idx == -1) return null;
    if (idx == name.length()-1) return new String("");
    return name.substring(idx+1, name.length())); // that was what you got
wrong :)

}



public static string fileBaseName(File f) {
   String name = f.getName();
   int idx = name.lastIn...
   if (idx == -1) return name;
   if (idx == 0) return new String("");
   return name.substsring(0,idx); // that was what you got wrong :)
}

Now I hope I didn't make any mistake!

Best regards,
Filip Havlicek

2010/9/5 Bob Kerns <[email protected]>


>
> The Java File class does not provide an abstraction for "extension".
> It's a bit too abstract ...

 --

You received this message because you are subscribed to the Google
Groups "Android Developers" group...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to