You can use System.getPropereties("os.name") to get the operating system's name. But the better way to do what you are trying to do is to use the static separator or separatorChar variables of the File class to determine what separator the OS uses. You can then construct a path:
Look at the API Docs for the File class for more information.
[edit note: My API link previously was linking to the J2EE API docs rather then the J2SE docs; sorry for any confusion] [ February 19, 2005: Message edited by: Mark Vedder ]
Joined: Jan 08, 2005
Originally posted by Nancy Zhang: so that my code could process current directory correctly, e.g. ".\" for windows usage, and "./" for unix usage. Thanks.
[ February 19, 2005: Message edited by: Nancy Zhang ]
It shouldn't matter, as already said, just use something like
Ands then when you need to refer to it, just replace any references to a slash for either OS and refer to the variable. This is better in my opinion.
Joined: Jul 11, 2001
If you need to concat directory names, you can also use the appropriate File constructor, so that you don't have to care about the seperator at all.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus