commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [fileUpload] Question about file name
Date Thu, 09 Jun 2005 20:46:25 GMT
On Thu, June 9, 2005 4:35 pm, Martin Cooper said:
> Nope. If the upload came from a Windows system and the server is
> running on *nix, then the system separator is *not* what you want.
> You'd be looking for '/' in a path that uses '\' as the separator.

Good point.

OK, so thinking simplistically..

    final char PATH_SEP = File.pathSeparatorChar;
    final char ANTI_PATH_SEP = File.pathSeparatorChar == '/' ? '\\' : '/';
    String test = "/sub/dev/test.txt";
    int lastSep;
    lastSep = test.lastIndexOf(PATH_SEP);
    if (lastSep == -1) {
      lastSep = test.lastIndexOf(ANTI_PATH_SEP);
    }

Should do the trick, no?

> Martin Cooper

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message