aspose file tools
The moose likes Java in General and the fly likes File.getName() in Unix Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "File.getName() in Unix" Watch "File.getName() in Unix" New topic
Author

File.getName() in Unix

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi all,

Has anyone encountered any issue with getName() function of File class in UNIX environment ? In windows platform getName() returns the name of the file ("filename.txt"), but the same is returning me the entire path in unix ("c:\folder\filename.txt").

Please let me know if there is any direct approach to resolve this issue ? I'm planning to find the last index of / and truncate the string

Thanks !
Rajeev
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24048
    
  13

"c:\folder\filename.txt" doesn't look like a path on UNIX; it looks like an (odd, but legal) filename, since "\" is not a directory separator on UNIX: "/" is. The File class knows how to work with paths and files on the local system, so on a UNIX system, it's not going to know what to do with your Windows paths.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: File.getName() in Unix
 
Similar Threads
help with file deletion...
How to write a program to download program
Class Loader Unable to load class
get file name using java on unix platform
How to write a program to download program