Java regex

Biedermann, Frank (SSABSA) frank at ssabsa.sa.gov.au
Tue Jun 7 00:56:55 CST 2005


> I've set basePath to be the the absolute pathname string, minus the
> filename itself:
> 
> String basePath = f.getAbsolutePath().replaceAll(f.getName(), "");
> 
> Any suggestions?

Yes, use:

String basePath = f.getCanonicalPath() instead.

That, in theory, should return the path to the file taking into account the
operating system's idiosyncrasies wrt forward/backwards slashes, drive
letters, mount points, etc. I had this problem a while back, and I think
this is what I did to get around it... Or maybe my memory's faulty...

HTH,

Frank


More information about the linuxsa mailing list